summary refs log tree commit diff
path: root/src/api/util/handlers/route.ts
diff options
context:
space:
mode:
authorCatalan Lover <48515417+FSG-Cat@users.noreply.github.com>2022-08-23 23:50:01 +0200
committerGitHub <noreply@github.com>2022-08-23 23:50:01 +0200
commitd63451b3fe6c0c6ab175adec82361834bb3633f5 (patch)
treeb738ee25bf9819300e1802ba9a8e2813e9dc2588 /src/api/util/handlers/route.ts
parentMerge pull request #1 from FSG-Cat/FSG-Cat-patch-1 (diff)
parentCheck Captcha (diff)
downloadserver-d63451b3fe6c0c6ab175adec82361834bb3633f5.tar.xz
Merge branch 'fosscord:staging' into Bug-Report-Template
Diffstat (limited to 'src/api/util/handlers/route.ts')
-rw-r--r--src/api/util/handlers/route.ts18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/api/util/handlers/route.ts b/src/api/util/handlers/route.ts
index 71e14955..d43ae103 100644
--- a/src/api/util/handlers/route.ts
+++ b/src/api/util/handlers/route.ts
@@ -1,8 +1,6 @@
 import {
 	DiscordApiErrors,
 	EVENT,
-	Event,
-	EventData,
 	FieldErrors,
 	FosscordApiErrors,
 	getPermission,
@@ -12,14 +10,14 @@ import {
 	RightResolvable,
 	Rights
 } from "@fosscord/util";
+import Ajv from "ajv";
+import addFormats from "ajv-formats";
+import { AnyValidateFunction } from "ajv/dist/core";
 import { NextFunction, Request, Response } from "express";
 import fs from "fs";
 import path from "path";
-import Ajv from "ajv";
-import { AnyValidateFunction } from "ajv/dist/core";
-import addFormats from "ajv-formats";
 
-const SchemaPath = path.join(__dirname, "..", "..", "..","..", "assets", "schemas.json");
+const SchemaPath = path.join(__dirname, "..", "..", "..", "..", "assets", "schemas.json");
 const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" }));
 
 export const ajv = new Ajv({
@@ -117,10 +115,10 @@ export function route(opts: RouteOptions) {
 			const valid = validate(normalizeBody(req.body));
 			if (!valid) {
 				const fields: Record<string, { code?: string; message: string }> = {};
-				if(process.env.LOG_INVALID_BODY) {
-					console.log(`Got invalid request: ${req.method} ${req.originalUrl}`)
-					console.log(req.body)
-					validate.errors?.forEach(x => console.log(x.params))
+				if (process.env.LOG_INVALID_BODY) {
+					console.log(`Got invalid request: ${req.method} ${req.originalUrl}`);
+					console.log(req.body);
+					validate.errors?.forEach((x) => console.log(x.params));
 				}
 				validate.errors?.forEach((x) => (fields[x.instancePath.slice(1)] = { code: x.keyword, message: x.message || "" }));
 				throw FieldErrors(fields);