import { listInvestigations, saveInvestigation, } from "@/lib/storage/server-investigation-persistence.js"; import { withAuthenticatedApi } from "@/lib/supabase/api-auth.js"; async function get() { try { return Response.json({ investigations: await listInvestigations() }); } catch { return Response.json({ error: "Investigation persistence request failed" }, { status: 500 }); } } async function post(request) { try { const { id, snapshot } = await request.json(); if (!id || !snapshot || typeof snapshot !== "object") { return Response.json({ error: "An investigation id and snapshot are required" }, { status: 400 }); } const savedSnapshot = await saveInvestigation(snapshot, id); return Response.json({ snapshot: savedSnapshot }, { status: 200 }); } catch { return Response.json({ error: "Investigation persistence request failed" }, { status: 500 }); } } export const GET = withAuthenticatedApi(get); export const POST = withAuthenticatedApi(post);