SPB Git

Repository Public

route.ts 2.6 KB 66 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/app/api/stats/report/route.ts9 * Module           : app10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-08-1712 * Last Modified    : 2026-08-1913 *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/**43 * GET /api/stats/report?mode=complet|synthese|tendances|repartitions|donnees44 * — rapport statistique PDF, moteur pdfkit vectoriel. Un mode inconnu retombe sur45 * « complet ». `period`/`from`/`to` sont acceptés mais non46 * applicables : les données sont un instantané du rôle 2026.47 * Alias historique : /api/report/stats.48 */49import { type NextRequest, NextResponse } from "next/server";50import { buildStatsReport, reportFilename, REPORT_MODES, type ReportMode } from "@/lib/report-stats";5152export async function GET(req: NextRequest) {53  const raw = req.nextUrl.searchParams.get("mode") ?? "complet";54  const mode: ReportMode = (REPORT_MODES as readonly string[]).includes(raw)55    ? (raw as ReportMode)56    : "complet";57  const pdf = await buildStatsReport(mode);58  return new NextResponse(new Uint8Array(pdf), {59    headers: {60      "Content-Type": "application/pdf",61      "Content-Disposition": `attachment; filename="${reportFilename(mode)}"`,62      "Cache-Control": "public, max-age=3600",63    },64  });65}66
Files main
Menu

Theme