Files
abode/src/webapi/schemarouter.ts
T
codingetandCodex 31d4636dde
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
ci: add pull request quality gates
Co-Authored-By: gpt-5.6-terra <noreply@openai.com>
2026-07-22 21:50:29 +00:00

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;
}