v1 review pass: fixed some minor bugs

This commit is contained in:
khannurien
2026-03-16 11:08:39 +00:00
parent e88fed4e98
commit 867e64cb5b
37 changed files with 1228 additions and 400 deletions

View File

@@ -87,7 +87,11 @@ router.put("/:dumpId/file", authMiddleware, async (ctx) => {
const dump = getDump(dumpId);
if (userId !== dump.userId) {
throw new APIException(APIErrorCode.UNAUTHORIZED, 401, "Not authorized to update dump");
throw new APIException(
APIErrorCode.UNAUTHORIZED,
401,
"Not authorized to update dump",
);
}
const formData = await ctx.request.body.formData();
@@ -95,7 +99,11 @@ router.put("/:dumpId/file", authMiddleware, async (ctx) => {
const comment = formData.get("comment");
if (!(file instanceof File)) {
throw new APIException(APIErrorCode.VALIDATION_ERROR, 400, "A file is required");
throw new APIException(
APIErrorCode.VALIDATION_ERROR,
400,
"A file is required",
);
}
const updatedDump = await replaceFileDump(
@@ -113,13 +121,21 @@ router.put("/:dumpId", authMiddleware, async (ctx) => {
const body = await ctx.request.body.json();
if (!isUpdateDumpRequest(body)) {
throw new APIException(APIErrorCode.VALIDATION_ERROR, 422, "Erroneous user input");
throw new APIException(
APIErrorCode.VALIDATION_ERROR,
422,
"Erroneous user input",
);
}
const dump = getDump(dumpId);
if (userId !== dump.userId) {
throw new APIException(APIErrorCode.UNAUTHORIZED, 401, "Not authorized to update dump");
throw new APIException(
APIErrorCode.UNAUTHORIZED,
401,
"Not authorized to update dump",
);
}
const updatedDump = await updateDump(dumpId, body);
@@ -133,7 +149,11 @@ router.delete("/:dumpId", authMiddleware, async (ctx) => {
const dump = getDump(dumpId);
if (userId !== dump.userId) {
throw new APIException(APIErrorCode.UNAUTHORIZED, 401, "Not authorized to delete dump");
throw new APIException(
APIErrorCode.UNAUTHORIZED,
401,
"Not authorized to delete dump",
);
}
await deleteDump(dumpId);