SPB Git forge

spb/toveli

Public
14commits 1branches 0releases
1.1 MBsize
maindefault branch
4 h agolast push
TypeScript 50.6% JavaScript 46.1% SQL 2.1% Shell 0.6% CSS 0.5%
858 B · 11 lines typescript
Raw Blame History
1import { NextRequest, NextResponse } from "next/server";2import { cityMetrics, marketIndex, marketMetrics, regionMetrics } from "@/lib/queries";3export const dynamic = "force-dynamic";4export function GET(req: NextRequest) {5  const sp = req.nextUrl.searchParams; const market = sp.get("marche") === "location" ? "rent" : "sale";6  try {7    if (sp.get("scope") && sp.get("value")) return NextResponse.json({ metrics: marketMetrics(sp.get("scope")!, sp.get("value")!, market) });8    return NextResponse.json({ regions: regionMetrics(market, sp.get("type") ?? "all"), cities: cityMetrics(market, sp.get("type") ?? "all"), index: market === "sale" ? marketIndex(sp.get("indice") ?? "unifamilial") : [] }, { headers: { "Cache-Control": "public, max-age=600" } });9  } catch (e) { return NextResponse.json({ error: (e as Error).message }, { status: 503 }); }10}11