import { NextRequest, NextResponse } from "next/server"; import { isExtAuthorized } from "@/lib/render-pipeline/ext-auth"; import { toErrorResponse } from "@/lib/render-pipeline/errors"; import { getLatestExport } from "@/lib/render-pipeline/exports"; // ── GET /api/ext/exports/latest?shotCode=&projectCode= (E2) ────────────────── // // Latest export + status for the AE panel status header. Returns // { "export": null } when the shot has never been exported. export async function GET(req: NextRequest) { if (!isExtAuthorized(req)) { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } const { searchParams } = new URL(req.url); const shotCode = searchParams.get("shotCode")?.trim(); const projectCode = searchParams.get("projectCode")?.trim(); if (!shotCode) { return NextResponse.json({ error: "shotCode query param is required" }, { status: 400 }); } try { const result = await getLatestExport(shotCode, projectCode); return NextResponse.json(result); } catch (err) { const { body, status } = toErrorResponse(err); return NextResponse.json(body, { status }); } }