feat: initial commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user