mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-29 22:34:33 +00:00
Cut down schemas by 90%
This commit is contained in:
@@ -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`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user