This commit is contained in:
NextJS
2026-05-05 20:02:40 +00:00
commit 0f6e979aac
51 changed files with 10161 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import { cookies } from "next/headers";
import { ADMIN_SESSION_COOKIE } from "@/lib/auth/session";
import {
parseMatchIdParam,
readMatchLogFile,
} from "@/lib/match-logs-server";
export async function GET(
_request: Request,
context: { params: Promise<{ matchId: string }> },
) {
const cookieStore = await cookies();
if (cookieStore.get(ADMIN_SESSION_COOKIE)?.value !== "1") {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
const { matchId: raw } = await context.params;
const matchId = parseMatchIdParam(raw);
if (matchId == null) {
return Response.json({ error: "Invalid match id" }, { status: 400 });
}
const result = await readMatchLogFile(matchId);
if (!result.ok) {
return Response.json({ error: result.message }, { status: result.status });
}
return Response.json({ matchId, content: result.content });
}