Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Vrai-Prix8 * File : src/app/api/avendre/comps/route.ts9 * Module : app10 * Repository : https://git.spboucher.ai/vrai-prix11 * Created : 2026-09-0812 * Last Modified : 2026-09-0813 *14 * Author : Simon-Pierre Boucher15 * Position : Professor of Finance16 * Institution : Université du Québec en Outaouais (UQO)17 * Organization : SP Boucher18 * Website : https://spboucher.ai19 * Git : https://git.spboucher.ai20 *21 * Preferred Contact: contact@spboucher.ai22 * Development : dev@spboucher.ai23 * Support : support@spboucher.ai24 * Security/Admin : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142// Auteur : Simon-Pierre Boucher — contact@spboucher.ai43// Bassin de comparables pour l'atelier « mon évaluation » d'une annonce.44import { NextRequest, NextResponse } from "next/server";45import { buildComps } from "@/lib/comps";4647export const dynamic = "force-dynamic";4849export function GET(req: NextRequest) {50 const q = req.nextUrl.searchParams;51 const uid = q.get("uid");52 if (!uid) return NextResponse.json({ error: "uid requis" }, { status: 400 });53 const num = (k: string) => {54 const v = Number(q.get(k));55 return Number.isFinite(v) && v > 0 ? v : undefined;56 };57 try {58 const res = buildComps(uid, {59 months: num("months"),60 radiusKm: num("radius"),61 includeListings: q.get("listings") !== "0",62 limit: num("limit"),63 });64 if (!res) return NextResponse.json({ error: "annonce introuvable ou non géolocalisée" }, { status: 404 });65 return NextResponse.json(res);66 } catch (e) {67 return NextResponse.json({ error: String(e) }, { status: 500 });68 }69}70