SPB Git

Repository Public

route.ts 2.1 KB 58 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/app/api/lead/route.ts9 * Module           : app10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-08-0912 * Last Modified    : 2026-08-0913 *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 */4142import { NextRequest, NextResponse } from "next/server";43import { saveLead } from "@/lib/local-db";4445export async function POST(req: NextRequest) {46  const body = (await req.json()) as {47    email?: string;48    unitId?: string;49    estimate?: number;50  };51  const email = body.email?.trim() ?? "";52  if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email)) {53    return NextResponse.json({ error: "courriel invalide" }, { status: 400 });54  }55  saveLead(email, body.unitId ?? null, body.estimate ?? null);56  return NextResponse.json({ ok: true });57}58
Files main
Menu

Theme