import { NextRequest, NextResponse } from "next/server"; import { Job } from "bullmq"; import { getPipelineQueue } from "@/lib/queue"; import type { PipelineJobData } from "@/lib/queue"; export const runtime = "nodejs"; export async function GET( _req: NextRequest, { params }: { params: Promise<{ id: string }> }, ) { const { id } = await params; const queue = getPipelineQueue(); const job = await Job.fromId(queue, id); if (!job) { return NextResponse.json({ error: "Job not found" }, { status: 404 }); } const state = await job.getState(); return NextResponse.json({ id: job.id, type: job.data.type, citySlug: job.data.citySlug, state, progress: job.progress ?? null, failedReason: job.failedReason ?? null, createdAt: job.timestamp, finishedAt: job.finishedOn ?? null, }); } export async function DELETE( _req: NextRequest, { params }: { params: Promise<{ id: string }> }, ) { const { id } = await params; const queue = getPipelineQueue(); const job = await Job.fromId(queue, id); if (!job) { return NextResponse.json({ error: "Job not found" }, { status: 404 }); } await job.remove(); return NextResponse.json({ removed: id }); }