SPB Git

Repository Public

route.ts 2.7 KB 74 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/app/sitemap-index.xml/route.ts9 * Module           : app10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-08-1312 * Last Modified    : 2026-08-1313 *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// Index de sitemaps (protocole sitemaps.org) : le sitemap des pages44// (/sitemap.xml) + les ~84 sitemaps des fiches (/estimation/sitemap/N.xml).45// C'est l'URL à soumettre dans Google Search Console.46import { getDb } from "@/lib/db";47import { SITE_URL } from "@/lib/seo";4849export const dynamic = "force-dynamic";5051const CHUNK = 45_000;5253export async function GET(): Promise<Response> {54  const max = (55    getDb().prepare("SELECT MAX(rowid) AS m FROM units").get() as { m: number }56  ).m;57  const n = Math.ceil(max / CHUNK);58  const locs = [59    `${SITE_URL}/sitemap.xml`,60    ...Array.from({ length: n }, (_, i) => `${SITE_URL}/estimation/sitemap/${i}.xml`),61  ];62  const xml =63    `<?xml version="1.0" encoding="UTF-8"?>\n` +64    `<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n` +65    locs.map((l) => `  <sitemap><loc>${l}</loc></sitemap>`).join("\n") +66    `\n</sitemapindex>\n`;67  return new Response(xml, {68    headers: {69      "Content-Type": "application/xml; charset=utf-8",70      "Cache-Control": "public, max-age=3600",71    },72  });73}74
Files main
Menu

Theme