TypeScript 61.9%
HTML 37.2%
SQL 0.7%
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