|
1 | 1 | /* eslint-disable @typescript-eslint/no-misused-promises, @typescript-eslint/require-await */
|
| 2 | +import $RefParser from '@apidevtools/json-schema-ref-parser' |
2 | 3 | import express, { Request, Response } from 'express'
|
3 | 4 | import { Server } from 'http'
|
4 | 5 | import { bootstrapSops } from 'src/cmd/bootstrap'
|
5 | 6 | import { validateValues } from 'src/cmd/validate-values'
|
6 | 7 | import { decrypt, encrypt } from 'src/common/crypt'
|
7 | 8 | import { terminal } from 'src/common/debug'
|
8 | 9 | import { hfValues } from './common/hf'
|
| 10 | +import { loadYaml, rootDir } from './common/utils' |
9 | 11 | import { objectToYaml } from './common/values'
|
10 | 12 |
|
11 | 13 | const d = terminal('server')
|
@@ -80,6 +82,13 @@ app.get('/otomi/values', async (req: Request, res: Response) => {
|
80 | 82 | }
|
81 | 83 | })
|
82 | 84 |
|
| 85 | +app.get('/apl/schema', async (req: Request, res: Response) => { |
| 86 | + const schema = await loadYaml(`${rootDir}/values-schema.yaml`) |
| 87 | + const derefSchema = await $RefParser.dereference(schema as $RefParser.JSONSchema) |
| 88 | + res.setHeader('Content-type', 'application/json') |
| 89 | + res.status(200).send(derefSchema) |
| 90 | +}) |
| 91 | + |
83 | 92 | export const startServer = (): void => {
|
84 | 93 | server = app.listen(17771, '0.0.0.0')
|
85 | 94 | d.log(`Server listening on http://0.0.0.0:17771`)
|
|
0 commit comments