import { NextRequest, NextResponse } from "next/server"; import { isExtAuthorized } from "@/lib/render-pipeline/ext-auth"; import { toErrorResponse } from "@/lib/render-pipeline/errors"; import { retryExport } from "@/lib/render-pipeline/exports"; // ── POST /api/ext/exports/{exportId}/retry (E14) ───────────────────────────── // // Retry a *_FAILED export from the AE panel: new RenderJob attempt, back to QUEUED. export async function POST( req: NextRequest, { params }: { params: Promise<{ exportId: string }> } ) { if (!isExtAuthorized(req)) { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } const { exportId } = await params; let note: string | undefined; try { const body = await req.json(); if (typeof body?.note === "string") note = body.note; } catch { // empty body is fine } try { const result = await retryExport(exportId, { type: "USER", note: note ?? "Retry from AE panel" }); return NextResponse.json(result); } catch (err) { const { body, status } = toErrorResponse(err); return NextResponse.json(body, { status }); } }