SPB Git forge

spb/cancerindex

Public
37commits 1branches 0releases
2.9 MBsize
maindefault branch
10 days agolast push
TypeScript 97.2% SQL 1.5% CSS 0.6% JavaScript 0.5%
708 B · 15 lines typescript
Raw Blame History
1import { NextResponse } from 'next/server';2import { searchEntities } from '@/lib/queries/search';34export const dynamic = 'force-dynamic';56/** GET /api/search?q=…&limit=… — entity search for the command palette and /search. */7export async function GET(req: Request) {8  const url = new URL(req.url);9  const q = (url.searchParams.get('q') ?? '').slice(0, 200);10  const limit = Math.min(50, Math.max(1, Number(url.searchParams.get('limit') ?? 20) || 20));11  if (q.trim().length < 2) return NextResponse.json({ data: [], query: q });12  const data = await searchEntities(q, limit);13  return NextResponse.json({ data, query: q }, { headers: { 'Cache-Control': 'public, max-age=30, s-maxage=120' } });14}15