← back to Wine Finder Next

app/api/wines/route.ts

12 lines

// app/api/wines/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { searchWines } from '@/lib/wines';

export async function GET(req: NextRequest) {
  const { searchParams } = new URL(req.url);
  const q = searchParams.get('q') || undefined;
  const limit = Number(searchParams.get('limit') || '50');

  const wines = searchWines(q, limit);
  return NextResponse.json({ wines });
}