SPB Git forge

spb/rareindex

Public
54commits 1branches 0releases
7.1 MBsize
maindefault branch
10 days agolast push
TypeScript 61.9% HTML 37.2% SQL 0.7%
777 B · 15 lines typescript
Raw Blame History
1import { NextResponse } from 'next/server';2import { getCurrentUser } from '@/lib/auth/session';3import { searchAssets } from '@/lib/account/queries';45export const dynamic = 'force-dynamic';67export async function GET(req: Request) {8  if (!(await getCurrentUser())) return NextResponse.json({ error: 'unauthorized' }, { status: 401 });9  const url = new URL(req.url);10  const q = (url.searchParams.get('q') ?? '').slice(0, 120);11  const category = url.searchParams.get('category') ?? undefined;12  const hits = await searchAssets(q, 12, category);13  return NextResponse.json(hits.map((h) => ({ id: h.id, title: h.title, categorySlug: h.categorySlug, year: h.year, heroImageUrl: h.heroImageUrl, rivUsd: h.rivUsd })), { headers: { 'cache-control': 'private, max-age=30' } });14}15