wulf-pulse/app/api/analyzer/jobs/[jobId]/route.ts

26 lines
679 B
TypeScript
Raw Normal View History

/**
* GET /api/analyzer/jobs/:jobId
*
* Returns the current status of an analyzer job. Frontend polls this every
* ~2 seconds during a run.
*/
import { NextResponse } from 'next/server';
import { requireAuth } from '@/lib/auth-utils';
import { getJob } from '@/lib/services/analyzer/persistence';
export async function GET(
_request: Request,
{ params }: { params: Promise<{ jobId: string }> }
) {
const { error } = await requireAuth();
if (error) return error;
const { jobId } = await params;
const job = await getJob(jobId);
if (!job) {
return NextResponse.json({ error: 'Job not found' }, { status: 404 });
}
return NextResponse.json({ job });
}