import { NextResponse } from "next/server"; import { auth } from "@/lib/auth"; import { memoAsync } from "@/lib/cache"; import { computePlayerStats } from "@/lib/player-stats"; export const dynamic = "force-dynamic"; export const runtime = "nodejs"; export async function GET() { const session = await auth(); if (!session) { return NextResponse.json({ error: "Unauthorized" }, { status: 403 }); } try { const data = await memoAsync("players:stats", 60_000, async () => computePlayerStats() ); return NextResponse.json(data, { headers: { "Cache-Control": "private, max-age=60" }, }); } catch (e) { return NextResponse.json( { error: (e as Error).message }, { status: 500 } ); } }