summary refs log tree commit diff
path: root/api/src/util/route.ts
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/util/route.ts')
-rw-r--r--api/src/util/route.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/api/src/util/route.ts b/api/src/util/route.ts
index 0302f3ec..f618a630 100644
--- a/api/src/util/route.ts
+++ b/api/src/util/route.ts
@@ -5,10 +5,20 @@ import path from "path";
 import Ajv from "ajv";
 import { AnyValidateFunction } from "ajv/dist/core";
 import { FieldErrors } from "..";
+import addFormats from "ajv-formats";
 
 const SchemaPath = path.join(__dirname, "..", "..", "assets", "schemas.json");
 const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" }));
-export const ajv = new Ajv({ allErrors: true, parseDate: true, allowDate: true, schemas, messages: true });
+export const ajv = new Ajv({
+	allErrors: true,
+	parseDate: true,
+	allowDate: true,
+	schemas,
+	messages: true,
+	strict: true,
+	strictRequired: true
+});
+addFormats(ajv);
 
 declare global {
 	namespace Express {
@@ -19,7 +29,7 @@ declare global {
 }
 
 export type RouteSchema = string; // typescript interface name
-export type RouteResponse = { status: number; body?: RouteSchema; headers?: Record<string, string> };
+export type RouteResponse = { status?: number; body?: RouteSchema; headers?: Record<string, string> };
 
 export interface RouteOptions {
 	permission?: PermissionResolvable;