Skip to content

Commit

Permalink
feat: serve values-schema to api endpoint (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisvankekem authored Aug 19, 2024
1 parent 015f8f8 commit 9401913
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* eslint-disable @typescript-eslint/no-misused-promises, @typescript-eslint/require-await */
import $RefParser from '@apidevtools/json-schema-ref-parser'
import express, { Request, Response } from 'express'
import { Server } from 'http'
import { bootstrapSops } from 'src/cmd/bootstrap'
import { validateValues } from 'src/cmd/validate-values'
import { decrypt, encrypt } from 'src/common/crypt'
import { terminal } from 'src/common/debug'
import { hfValues } from './common/hf'
import { loadYaml, rootDir } from './common/utils'
import { objectToYaml } from './common/values'

const d = terminal('server')
Expand Down Expand Up @@ -80,6 +82,13 @@ app.get('/otomi/values', async (req: Request, res: Response) => {
}
})

app.get('/apl/schema', async (req: Request, res: Response) => {
const schema = await loadYaml(`${rootDir}/values-schema.yaml`)
const derefSchema = await $RefParser.dereference(schema as $RefParser.JSONSchema)
res.setHeader('Content-type', 'application/json')
res.status(200).send(derefSchema)
})

export const startServer = (): void => {
server = app.listen(17771, '0.0.0.0')
d.log(`Server listening on http://0.0.0.0:17771`)
Expand Down

0 comments on commit 9401913

Please sign in to comment.