TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1import { withUser, json, ApiError } from "@/lib/api";2import { getArenaScoreboard } from "@/lib/arena/service";3import { CRITERION_RE, isTaskCategory } from "@/lib/arena/scoring";45export const dynamic = "force-dynamic";67/**8 * GET /api/arena/scoreboard?category=coding|research|writing|reasoning|general&criterion=best|value|…9 * → { rows: ScoreboardRow[], sessions, votes }10 */11export const GET = withUser(async ({ req, user }) => {12 const url = new URL(req.url);13 const category = url.searchParams.get("category") || null;14 const criterion = url.searchParams.get("criterion") || null;15 if (category && !isTaskCategory(category)) throw new ApiError(400, "Unknown category", "VALIDATION_ERROR");16 if (criterion && !CRITERION_RE.test(criterion)) throw new ApiError(400, "Unknown criterion", "VALIDATION_ERROR");17 return json(await getArenaScoreboard(user.id, { category: category && isTaskCategory(category) ? category : null, criterion }));18});19