import { projectRef } from "@/lib/projects"; import { postBenchData } from "@/lib/report/postBenchData"; export const dynamic = "force-dynamic"; // THE POST BENCH'S DATA as JSON, for the workspace's inspector (components/projects/workspace/): one post // item of the draft as PostBench draws it. // GET ?project=&id= // // The same function the bench's own page renders from (lib/report/postBenchData.ts), so the inspector and // the page cannot disagree. An id that is not a post item of the cut is a 404, as the page's. export async function GET(request: Request) { const q = new URL(request.url).searchParams; const project = await projectRef(q.get("project") ?? ""); if (!project) return Response.json({ error: "no such project" }, { status: 404 }); const id = q.get("id") ?? ""; const r = await postBenchData(project.dir, id); if (!r) return Response.json({ error: `${id} is not a post item of the cut` }, { status: 404 }); return Response.json(r, { headers: { "cache-control": "no-store" } }); }