2 files changed, 4 insertions, 3 deletions
diff --git a/src/middlewares/ErrorHandler.ts b/src/middlewares/ErrorHandler.ts
index 52fa949c..28ff7e6c 100644
--- a/src/middlewares/ErrorHandler.ts
+++ b/src/middlewares/ErrorHandler.ts
@@ -23,7 +23,8 @@ export function ErrorHandler(error: Error, req: Request, res: Response, next: Ne
}
res.status(httpcode).json({ code: code, message, errors });
- return next();
+
+ return;
} catch (error) {
console.error(error);
return res.status(500).json({ code: 500, message: "Internal Server Error" });
diff --git a/src/util/instanceOf.ts b/src/util/instanceOf.ts
index 4f30bd46..eb2894cd 100644
--- a/src/util/instanceOf.ts
+++ b/src/util/instanceOf.ts
@@ -114,8 +114,6 @@ export function instanceOf(
}
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(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
@@ -154,6 +152,8 @@ export function instanceOf(
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(
Object.keys(type).map((x) => (x.startsWith(OPTIONAL_PREFIX) ? x.slice(OPTIONAL_PREFIX.length) : x))
);
|