diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-09-17 19:38:54 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-09-17 19:38:54 +0200 |
commit | 15b79052c88ce30a713c6f942cedf01211b50a5f (patch) | |
tree | cc444dce096a314e7fa2700a07858039d7ee8a61 /src/cdn/routes/role-icons.ts | |
parent | Add register ratelimit (diff) | |
download | server-15b79052c88ce30a713c6f942cedf01211b50a5f.tar.xz |
Partially refactor code to use localization
Diffstat (limited to '')
-rw-r--r-- | src/cdn/routes/role-icons.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cdn/routes/role-icons.ts b/src/cdn/routes/role-icons.ts index 768e194f..4449f9d1 100644 --- a/src/cdn/routes/role-icons.ts +++ b/src/cdn/routes/role-icons.ts @@ -17,8 +17,8 @@ const ALLOWED_MIME_TYPES = [...STATIC_MIME_TYPES]; const router = Router(); router.post("/:role_id", multer.single("file"), async (req: Request, res: Response) => { - if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); - if (!req.file) throw new HTTPError("Missing file"); + if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError(req.t("common:body.INVALID_REQUEST_SIGNATURE")); + if (!req.file) throw new HTTPError(req.t("common:body.MISSING_FILE")); const { buffer, mimetype, size, originalname, fieldname } = req.file; const { role_id } = req.params; @@ -46,7 +46,7 @@ router.get("/:role_id", async (req: Request, res: Response) => { const path = `role-icons/${role_id}`; const file = await storage.get(path); - if (!file) throw new HTTPError("not found", 404); + if (!file) throw new HTTPError(req.t("common:notfound.FILE"), 404); const type = await FileType.fromBuffer(file); res.set("Content-Type", type?.mime); @@ -61,7 +61,7 @@ router.get("/:role_id/:hash", async (req: Request, res: Response) => { const path = `role-icons/${role_id}/${hash}`; const file = await storage.get(path); - if (!file) throw new HTTPError("not found", 404); + if (!file) throw new HTTPError(req.t("common:notfound.FILE"), 404); const type = await FileType.fromBuffer(file); res.set("Content-Type", type?.mime); @@ -71,7 +71,7 @@ router.get("/:role_id/:hash", async (req: Request, res: Response) => { }); router.delete("/:role_id/:id", async (req: Request, res: Response) => { - if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError("Invalid request signature"); + if (req.headers.signature !== Config.get().security.requestSignature) throw new HTTPError(req.t("common:body.INVALID_REQUEST_SIGNATURE")); const { role_id, id } = req.params; const path = `role-icons/${role_id}/${id}`; |