import { ScaffoldError, scaffoldProject } from "@/lib/projects/scaffold"; export const dynamic = "force-dynamic"; // One "new project" door, whatever the kind. The body names the kind and what // that kind's scaffold asks for; the dispatch lives in lib/projects/scaffold.ts // so this file never branches on a kind id. Supersedes /api/browse/init. export async function POST(request: Request) { let body: Record; try { body = await request.json(); } catch { return Response.json({ error: "bad json" }, { status: 400 }); } try { const r = await scaffoldProject(body); return Response.json({ ok: true, ...r }, { headers: { "cache-control": "no-store" } }); } catch (e) { const status = e instanceof ScaffoldError ? e.status : 500; return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status }); } }