🐛 fix body parser
This commit is contained in:
parent
cf70e8cff6
commit
c0fd1d1f2f
@ -23,7 +23,8 @@ export function ErrorHandler(error: Error, req: Request, res: Response, next: Ne
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.status(httpcode).json({ code: code, message, errors });
|
res.status(httpcode).json({ code: code, message, errors });
|
||||||
return next();
|
|
||||||
|
return;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return res.status(500).json({ code: 500, message: "Internal Server Error" });
|
return res.status(500).json({ code: 500, message: "Internal Server Error" });
|
||||||
|
@ -114,8 +114,6 @@ export function instanceOf(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof type === "object") {
|
if (typeof type === "object") {
|
||||||
if (typeof value !== "object") throw new FieldError("BASE_TYPE_OBJECT", req.t("common:field.BASE_TYPE_OBJECT"));
|
|
||||||
|
|
||||||
if (Array.isArray(type)) {
|
if (Array.isArray(type)) {
|
||||||
if (!Array.isArray(value)) throw new FieldError("BASE_TYPE_ARRAY", req.t("common:field.BASE_TYPE_ARRAY"));
|
if (!Array.isArray(value)) throw new FieldError("BASE_TYPE_ARRAY", req.t("common:field.BASE_TYPE_ARRAY"));
|
||||||
if (!type.length) return true; // type array didn't specify any type
|
if (!type.length) return true; // type array didn't specify any type
|
||||||
@ -154,6 +152,8 @@ export function instanceOf(
|
|||||||
throw new FieldError("BASE_TYPE_CLASS", req.t("common:field.BASE_TYPE_CLASS", { type }));
|
throw new FieldError("BASE_TYPE_CLASS", req.t("common:field.BASE_TYPE_CLASS", { type }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof value !== "object") throw new FieldError("BASE_TYPE_OBJECT", req.t("common:field.BASE_TYPE_OBJECT"));
|
||||||
|
|
||||||
const diff = Object.keys(value).missing(
|
const diff = Object.keys(value).missing(
|
||||||
Object.keys(type).map((x) => (x.startsWith(OPTIONAL_PREFIX) ? x.slice(OPTIONAL_PREFIX.length) : x))
|
Object.keys(type).map((x) => (x.startsWith(OPTIONAL_PREFIX) ? x.slice(OPTIONAL_PREFIX.length) : x))
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user