diff --git a/src/app/api/run/route.ts b/src/app/api/run/route.ts index 760f0b5..b529d1f 100644 --- a/src/app/api/run/route.ts +++ b/src/app/api/run/route.ts @@ -36,10 +36,10 @@ export async function PUT(req: NextRequest) { } export async function POST(req: NextRequest) { - const { runId } = await req.json(); + const runId = req.nextUrl.searchParams.get("runId"); if (!runId) - return NextResponse.json({ error: "body requires runId" }, { status: 400 }); + return NextResponse.json({ error: "missing ?runId=" }, { status: 400 }); const supabase = await createClient(); @@ -60,3 +60,21 @@ export async function POST(req: NextRequest) { return NextResponse.json({ ok: true, run }); } + +export async function DELETE(req: NextRequest) { + const { runId } = await req.json(); + + if (!runId) + return NextResponse.json({ error: "body requires runId" }, { status: 400 }); + + const supabase = await createClient(); + + const session = await getSession(supabase); + + if (!session) + return NextResponse.json({ error: "Invalid session" }, { status: 401 }); + + const run = await Core.removeLiveRun(runId); + + return NextResponse.json({ ok: true, run }); +}