From 239770c8b6407300badd68a0b5336c2542bd6ff5 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Sun, 8 Feb 2026 14:22:45 +0100 Subject: [PATCH] Cancel run --- src/app/api/run/route.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 }); +}