import { prisma } from "@/lib/prisma"; import { CHUNK_SIZE } from "../sitemap"; import { NextResponse } from "next/server"; export const revalidate = 43200; // update every 12 hours export async function GET() { const apiUrl = process.env.NEXT_PUBLIC_BASE_URL!; const total = await prisma.mii.count({ where: { in_queue: false, quarantined: false }, }); const miiChunks = Math.ceil(total / CHUNK_SIZE); const totalSitemaps = miiChunks + 1; // +1 for the static-routes sitemap const sitemapEntries = Array.from({ length: totalSitemaps }, (_, i) => `${apiUrl}/sitemap/${i}.xml`).join(""); const xml = ` ${sitemapEntries} `; return new NextResponse(xml, { headers: { "Content-Type": "application/xml" }, }); }