Edge /api/vehicles (RDW NL, live now) + /api/screen (OpenSanctions, live now), both defer to engine when ENGINE_URL set. Engine: /vehicles/{plate} + /screen endpoints; workers/resolve (blocking+fuzzy entity resolution, now used by pipeline); workers/queue (in-process job queue); sources/financials (Companies House accounts + XBRL path). py_compile + tsc + next build green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { engineFetch } from "@/lib/engine";
|
|
|
|
// GET /api/screen?q=Name — OpenSanctions screening (sanctions/PEP). VERIFY
|
|
// commercial terms before production volume. Defers to engine when running.
|
|
export async function GET(req: NextRequest) {
|
|
const q = req.nextUrl.searchParams.get("q") ?? "";
|
|
if (!q) return NextResponse.json({ matches: [] });
|
|
|
|
const eng = await engineFetch(`/screen?q=${encodeURIComponent(q)}`);
|
|
if (eng && eng.ok) return NextResponse.json(await eng.json());
|
|
|
|
try {
|
|
const r = await fetch(`https://api.opensanctions.org/search/default?q=${encodeURIComponent(q)}&limit=5`, {
|
|
headers: { "User-Agent": "0pt/0.1 (+https://0pt.app; SIAX)" },
|
|
cache: "no-store",
|
|
});
|
|
if (!r.ok) return NextResponse.json({ matches: [], source: "opensanctions" });
|
|
const data = (await r.json()) as { results?: { caption?: string; score?: number; schema?: string }[] };
|
|
return NextResponse.json({
|
|
source: "opensanctions",
|
|
matches: (data.results ?? []).map((x) => ({ name: x.caption ?? null, score: x.score ?? null, schema: x.schema ?? null })),
|
|
});
|
|
} catch {
|
|
return NextResponse.json({ matches: [], source: "opensanctions" });
|
|
}
|
|
}
|