TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1import { withUser, parseBody, json } from "@/lib/api";2import { arenaRetractVoteSchema, arenaVoteSchema } from "@/lib/chat/schemas";3import { castArenaVote, retractArenaVote } from "@/lib/arena/service";4import { LIMITS } from "@/lib/rate-limit";56export const dynamic = "force-dynamic";78/**9 * POST /api/arena/vote { sessionId, responseId, criterion, category? }10 * → { votes, ratings } — upserts the vote for (session, criterion); legacy ratings mirrored.11 */12export const POST = withUser(13 async ({ req, user }) => {14 const body = await parseBody(req, arenaVoteSchema);15 return json(await castArenaVote(user.id, body));16 },17 { limit: { max: 120, windowMs: 60_000, key: "arena-vote" } },18);1920/** DELETE /api/arena/vote { sessionId, criterion } → { votes, ratings } — retracts the vote. */21export const DELETE = withUser(22 async ({ req, user }) => {23 const body = await parseBody(req, arenaRetractVoteSchema);24 return json(await retractArenaVote(user.id, body));25 },26 { limit: { max: LIMITS.arena.max * 6, windowMs: LIMITS.arena.windowMs, key: "arena-vote" } },27);28