import { caseView, patchCase } from "@/lib/research/boards"; import { CaseError } from "@/lib/research/cases.mjs"; import { fail, ok } from "../../_respond"; export const dynamic = "force-dynamic"; // One case (the API is documented in ../route.ts). // GET -> CaseView // PATCH { title?, notes?, scope?, sections?, order? } -> CaseView export async function GET(_request: Request, ctx: { params: Promise<{ id: string }> }) { try { const { id } = await ctx.params; return ok(await caseView(id)); } catch (e) { return fail(e); } } export async function PATCH(request: Request, ctx: { params: Promise<{ id: string }> }) { try { const { id } = await ctx.params; const body = (await request.json().catch(() => null)) as Record | null; if (!body || typeof body !== "object" || Array.isArray(body)) throw new CaseError("expected a JSON object: { title?, notes?, scope?, sections?, order? }"); await patchCase(id, body); return ok(await caseView(id)); } catch (e) { return fail(e); } }