reformat
This commit is contained in:
1 parent
64b8aab4d6
commit
f65238da6c
4 files changed
+11
-7
No files matched your search
@@ -7,8 +7,7 @@ import { AppError } from "@/utils/AppError.js";
|
||||
const multerErrorStatus = (error: MulterError): number => (error.code === "LIMIT_FILE_SIZE" ? 413 : 400);
|
||||
|
||||
const handleErrors = (error: unknown, req: Request, res: Response, _next: NextFunction) => {
|
||||
const status =
|
||||
error instanceof MulterError ? multerErrorStatus(error) : error instanceof AppError ? error.status || 500 : 500;
|
||||
const status = error instanceof MulterError ? multerErrorStatus(error) : error instanceof AppError ? error.status || 500 : 500;
|
||||
const message = error instanceof AppError ? error.message : error instanceof Error ? error.message : "Server error";
|
||||
const service = error instanceof AppError ? error.service : error instanceof MulterError ? "uploadMiddleware" : "unknownService";
|
||||
const method = error instanceof AppError ? error.method : "unknownMethod";
|
||||
|
||||
@@ -30,7 +30,13 @@ class AuthRoutes {
|
||||
this.router.patch("/users/:userId/password", verifyJWT, isAllowed(["superadmin"]), this.authController.editUserPasswordById);
|
||||
this.router.delete("/users/:userId", verifyJWT, isAllowed(["admin", "superadmin"]), this.authController.deleteUserById);
|
||||
|
||||
this.router.patch("/user", verifyJWT, imageUpload.single("profileImage"), isAllowed(["admin", "superadmin", "user"]), this.authController.editUser);
|
||||
this.router.patch(
|
||||
"/user",
|
||||
verifyJWT,
|
||||
imageUpload.single("profileImage"),
|
||||
isAllowed(["admin", "superadmin", "user"]),
|
||||
this.authController.editUser
|
||||
);
|
||||
this.router.delete("/user", verifyJWT, isAllowed(["admin", "superadmin", "user"]), this.authController.deleteUser);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { boolean, z } from "zod";
|
||||
import { z } from "zod";
|
||||
import { DbTypes, QueueModes } from "@/domain/app-settings/app-settings.type.js";
|
||||
import { booleanCoercion } from "@/api/validation/shared.js";
|
||||
|
||||
|
||||
@@ -6,10 +6,9 @@ import { AppError } from "../../../src/utils/AppError.ts";
|
||||
|
||||
// Reaches into the multer instance config to exercise the fileFilter/limits in isolation.
|
||||
// Guards against regressing GHSA-9xvg-x28f-m78m (pre-auth DoS via unbounded uploads).
|
||||
const config = (imageUpload as unknown as { fileFilter: Function; limits: { fileSize: number; files: number } });
|
||||
const config = imageUpload as unknown as { fileFilter: Function; limits: { fileSize: number; files: number } };
|
||||
|
||||
const makeFile = (mimetype: string): Express.Multer.File =>
|
||||
({ fieldname: "profileImage", originalname: "x", mimetype }) as Express.Multer.File;
|
||||
const makeFile = (mimetype: string): Express.Multer.File => ({ fieldname: "profileImage", originalname: "x", mimetype }) as Express.Multer.File;
|
||||
|
||||
const runFilter = (mimetype: string): Promise<{ error: unknown; accepted: unknown }> =>
|
||||
new Promise((resolve) => {
|
||||
|
||||
Reference in new issue
Block a user