v3: code quality pass, various bug fixes
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
isUpdateCommentRequest,
|
||||
} from "../model/interfaces.ts";
|
||||
import { authMiddleware } from "../middleware/auth.ts";
|
||||
import { verifyJWT } from "../lib/jwt.ts";
|
||||
import { parseOptionalAuth } from "../lib/auth.ts";
|
||||
import {
|
||||
createComment,
|
||||
deleteComment,
|
||||
@@ -26,12 +26,7 @@ const router = new Router({ prefix: "/api" });
|
||||
|
||||
// GET /api/dumps/:dumpId/comments — optional auth (to access private dump comments)
|
||||
router.get("/dumps/:dumpId/comments", async (ctx) => {
|
||||
let requestingUserId: string | undefined;
|
||||
const authHeader = ctx.request.headers.get("Authorization");
|
||||
if (authHeader?.startsWith("Bearer ")) {
|
||||
const payload = await verifyJWT(authHeader.substring(7));
|
||||
if (payload) requestingUserId = payload.userId;
|
||||
}
|
||||
const requestingUserId = await parseOptionalAuth(ctx) ?? undefined;
|
||||
const dump = getDump(ctx.params.dumpId, requestingUserId);
|
||||
const comments = getComments(dump.id);
|
||||
const responseBody: APIResponse<Comment[]> = {
|
||||
|
||||
Reference in New Issue
Block a user