import { cancelPhraseScan, phraseScanView } from "@/lib/phrase-finder/server"; export const dynamic = "force-dynamic"; // One search: GET its state, progress and, once done, each phrase's numbers; // DELETE stops it while it runs. export async function GET(_request: Request, ctx: { params: Promise<{ id: string }> }) { const { id } = await ctx.params; const view = await phraseScanView(id); if (!view) return Response.json({ error: "no such search" }, { status: 404 }); return Response.json(view, { headers: { "cache-control": "no-store" } }); } export async function DELETE(_request: Request, ctx: { params: Promise<{ id: string }> }) { const { id } = await ctx.params; return Response.json({ cancelled: cancelPhraseScan(id) }, { headers: { "cache-control": "no-store" } }); }