Files
game-scoreboard/src/app/api/judge/[token]/route.ts
T
joshuaandClaude Opus 5.5 2702491096 Phase 7: judges — links, phone page, open link, judged control room
- Setup: nominate judges, copy personal links, QR codes (generated on
  demand in the browser), revoke/restore, and an open-link toggle.
- GET /api/judge/[token] returns only that judge's own scores; PUT
  .../scores runs every check from ARCHITECTURE.md in checkJudgeWrite
  (pure, unit-tested) after one parallel lookup, plus a rate limit.
- /j/[token]: mobile cards per team, spotlight pinned first, autosave
  with per-card status, read-only when locked/done, link-off when revoked.
- /jo/[token]: name form -> personal link, remembered in localStorage so
  a re-scan doesn't create a second judge.
- Control room: averages with on-request overrides, judge progress
  matrix, per-judge breakdown, spotlight select and lock toggle.
- usePendingEdits shares the optimistic autosave logic between the admin
  grid and the judge page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 15:29:33 +02:00

18 lines
685 B
TypeScript

import { NextResponse } from "next/server";
import { getJudgePayload } from "@/lib/judge.server";
const headers = { "Cache-Control": "no-store" };
export async function GET(_request: Request, context: RouteContext<"/api/judge/[token]">) {
const { token } = await context.params;
try {
const result = await getJudgePayload(token);
if (!result.ok) return NextResponse.json({ error: result.error }, { status: result.status, headers });
return NextResponse.json(result.payload, { headers });
} catch (error) {
console.error("judge API failed", error);
return NextResponse.json({ error: "Could not load the game. Try again." }, { status: 500, headers });
}
}