// Auteur : Simon-Pierre Boucher — contact@spboucher.ai import { NextRequest, NextResponse } from "next/server"; import { searchUnits } from "@/lib/db"; export function GET(req: NextRequest) { const q = req.nextUrl.searchParams.get("q") ?? ""; if (q.trim().length < 3) return NextResponse.json({ results: [] }); try { const results = searchUnits(q, 8).map((u) => ({ id: u.id_provinc, adresse: u.adresse, apt: u.apt, municipalite: u.municipalite, typeProp: u.type_prop, })); return NextResponse.json({ results }); } catch { return NextResponse.json({ results: [] }); } }