import { NextResponse } from "next/server";

import { requireApiAccess } from "../../../../../lib/api/auth";
import { getWorkflowProgress } from "../../../../../lib/workflow/progress-store";

interface RouteContext {
  params: Promise<{ jobId: string }>;
}

export async function GET(request: Request, context: RouteContext) {
  const access = requireApiAccess(request);
  if (!access.ok) {
    return access.response;
  }

  const { jobId } = await context.params;
  return NextResponse.json({ progress: getWorkflowProgress(jobId) });
}
