CI / install-and-build (pull_request) Successful in 1m29s
CI / format (pull_request) Successful in 51s
CI / typecheck-source (pull_request) Successful in 41s
CI / typecheck-tests (pull_request) Successful in 39s
CI / test (pull_request) Successful in 51s
CI / lint (pull_request) Successful in 21s
Co-Authored-By: gpt-5.6-terra <noreply@openai.com>
31 lines
722 B
TypeScript
31 lines
722 B
TypeScript
import KoaRouter from "@koa/router";
|
|
import * as validators from "../schema/validators.js";
|
|
|
|
export function schemarouter(): KoaRouter {
|
|
const router = new KoaRouter();
|
|
|
|
router.get("/", (ctx) => {
|
|
ctx.body = Object.fromEntries(
|
|
Object.entries(validators).map(([name, { schema }]) => {
|
|
return [
|
|
name,
|
|
{
|
|
$id: schema.$id,
|
|
title: schema.title,
|
|
description: schema.description,
|
|
url: `${ctx.URL}/${name}.schema.json`,
|
|
},
|
|
];
|
|
}),
|
|
);
|
|
});
|
|
|
|
for (const [name, { schema }] of Object.entries(validators)) {
|
|
router.get(`/${name}.schema.json`, (ctx) => {
|
|
ctx.body = schema;
|
|
});
|
|
}
|
|
|
|
return router;
|
|
}
|