import { getSessionAccount } from "@/lib/auth/require-session"; import { canReadPage } from "@/lib/auth/permissions"; import { parseMatchmakerLogParam } from "@/lib/matchmaker-log-source"; import { readMatchmakerLogFile } from "@/lib/matchmaker-logs-server"; const NO_STORE = { "Cache-Control": "no-store, max-age=0" }; export async function GET(request: Request) { const account = await getSessionAccount(); if (!account || !canReadPage(account, "matchmaker")) { return Response.json( { error: "Unauthorized" }, { status: 401, headers: NO_STORE }, ); } const { searchParams } = new URL(request.url); const source = parseMatchmakerLogParam(searchParams.get("mklog")); const result = await readMatchmakerLogFile(source); if (!result.ok) { return Response.json( { error: result.message }, { status: result.status, headers: NO_STORE }, ); } return Response.json( { content: result.content }, { headers: NO_STORE }, ); }