import { NextRequest, NextResponse } from "next/server"; import { unifiedSearch, unifiedPoints } from "@/lib/search"; import { fromUrl } from "@/lib/search-params"; export const dynamic = "force-dynamic"; export async function GET(req: NextRequest) { const sp = Object.fromEntries(req.nextUrl.searchParams.entries()); const p = fromUrl(sp, Math.min(Number(sp.limit ?? 24) || 24, 200)); try { if (sp.format === "points") return NextResponse.json({ points: await unifiedPoints({ ...p, limit: 2000 }) }, { headers: { "Cache-Control": "public, max-age=120" } }); return NextResponse.json(await unifiedSearch(p), { headers: { "Cache-Control": "public, max-age=120" } }); } catch (e) { return NextResponse.json({ error: (e as Error).message }, { status: 503 }); } }