Cut down schemas by 90%

This commit is contained in:
Rory&
2025-11-29 22:22:41 +01:00
parent 60a24f0e39
commit 2ebe2a57fb
16 changed files with 302 additions and 82 deletions
+7 -1
View File
@@ -87,7 +87,13 @@ export interface RouteOptions {
export function route(opts: RouteOptions) {
let validate: AnyValidateFunction | undefined;
if (opts.requestBody) {
validate = ajv.getSchema(opts.requestBody);
try {
validate = ajv.getSchema(opts.requestBody);
} catch (e) {
console.error("AJV getSchema failed!");
throw e;
}
if (!validate)
throw new Error(`Body schema ${opts.requestBody} not found`);
}