import { buildsIn, usageIndex, usesOf } from "@/lib/usage"; export const dynamic = "force-dynamic"; // `?key=` asks about one clip; no key gives the index's shape, which is what a // header wants. Both are cheap after the first call -- the index is rebuilt only // when a plan file's mtime changes, i.e. when something has actually been // rendered. export async function GET(request: Request) { const key = new URL(request.url).searchParams.get("key"); if (!key) { const idx = await usageIndex(); return Response.json( { builds: idx.builds, clips: idx.clips }, { headers: { "cache-control": "no-store" } }, ); } const uses = await usesOf(key); return Response.json( { key, uses, builds: buildsIn(uses) }, { headers: { "cache-control": "no-store" } }, ); }