SPB Git

Repository Public

route.ts 3.1 KB 86 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/app/api/ventes/route.ts9 * Module           : app10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-10-2012 * Last Modified    : 2026-10-2013 *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// Registre des ventes récentes en JSON (mêmes filtres que /ventes) :44//   GET /api/ventes?q=Québec&type=condo&min=200000&max=600000&periode=90&page=1&limit=5045import { NextRequest, NextResponse } from "next/server";46import { parseVenteFilters, ventesOverview, ventesRecentes, vsRolePct } from "@/lib/ventes";4748export function GET(req: NextRequest) {49  const f = parseVenteFilters(req.nextUrl.searchParams);50  try {51    const page = ventesRecentes(f);52    const ov = ventesOverview();53    return NextResponse.json(54      {55        source: "Transactions publiées — flux Journal de Québec / Journal de Montréal (api.qub.ca)",56        updatedTo: ov.maxDate,57        total: page.total,58        page: page.page,59        pages: page.pages,60        limit: page.limit,61        since: page.since,62        filters: page.filters,63        rows: page.rows.map((r) => ({64          id: r.id,65          date: r.date,66          amount: r.amount,67          street: r.street,68          city: r.city,69          propertyType: r.property_type,70          yearBuilt: r.year_built,71          floorArea: r.floor_area,72          landArea: r.land_area,73          idProvinc: r.id_provinc,74          valeurRole: r.valeur_role,75          lat: r.lat ?? null,76          lng: r.lng ?? null,77          vsRolePct: vsRolePct(r.amount, r.valeur_role),78        })),79      },80      { headers: { "Cache-Control": "public, max-age=300, s-maxage=600" } }81    );82  } catch (e) {83    return NextResponse.json({ error: (e as Error).message }, { status: 500 });84  }85}86
Files main
Menu

Theme