import { NextResponse } from 'next/server';
import { getSeedanceVideoTask } from '@/lib/videoProviders';

export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';

export async function GET(_req: Request, ctx: { params: Promise<{ taskId: string }> }) {
  const { taskId } = await ctx.params;
  try {
    return NextResponse.json(await getSeedanceVideoTask(taskId));
  } catch (error) {
    const message = String(error);
    return NextResponse.json({ error: message }, {
      status: message.includes('SEEDANCE_API_KEY missing') ? 503 : 500,
    });
  }
}
