diff --git a/api/src/util/handlers/route.ts b/src/api/util/handlers/route.ts
index eaf7dc91..71e14955 100644
--- a/api/src/util/handlers/route.ts
+++ b/src/api/util/handlers/route.ts
@@ -19,7 +19,7 @@ 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,6 +117,11 @@ 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))
+ }
validate.errors?.forEach((x) => (fields[x.instancePath.slice(1)] = { code: x.keyword, message: x.message || "" }));
throw FieldErrors(fields);
}
|