export const runtime = "nodejs"; export const dynamic = "force-dynamic"; import { type NextRequest, NextResponse } from "next/server"; import { AsrBatchJobError, createAsrBatchJob, getActiveAsrBatchJob, listAsrBatchJobs, } from "@/lib/asr-batch-jobs"; export async function GET() { return NextResponse.json({ jobs: listAsrBatchJobs(), activeJob: getActiveAsrBatchJob(), }); } export async function POST(req: NextRequest) { let body: unknown; try { body = await req.json(); } catch { return NextResponse.json({ error: "Invalid JSON body" }, { status: 400 }); } try { const job = await createAsrBatchJob( body && typeof body === "object" ? body : {}, ); return NextResponse.json({ job }, { status: 201 }); } catch (error) { if (error instanceof AsrBatchJobError) { return NextResponse.json( { error: error.message }, { status: error.status }, ); } console.error("Failed to create ASR batch job:", error); return NextResponse.json( { error: "Failed to create ASR batch job" }, { status: 500 }, ); } }