import { loadClipList } from "@/lib/clips"; import { isMode } from "@/lib/types"; export const dynamic = "force-dynamic"; // The queue as JSON. The page renders it server-side, but having it addressable // makes the tool scriptable -- checking what a mode currently holds, or driving // it from a test, should not mean scraping a flight payload. export async function GET(request: Request) { const url = new URL(request.url); const mode = url.searchParams.get("mode") ?? "sort"; if (!isMode(mode)) return Response.json({ error: "unknown mode" }, { status: 400 }); const limit = Math.max(1, Math.min(4000, Number(url.searchParams.get("limit") ?? 200))); const only = url.searchParams.get("only")?.split(",").map((s) => s.trim()).filter(Boolean); return Response.json(await loadClipList({ mode, limit, only }), { headers: { "cache-control": "no-store" }, }); }