import { HEALTH_HEADER, healthBody, healthReport } from "@peppa/core"; import { bootId } from "@/lib/boot"; import { db } from "@/lib/db"; export const dynamic = "force-dynamic"; /** * Health check (PEP-20): DB, version, service heartbeats. 503 if the DB is down. * PEP-272: without the internal key (`X-Peppa-Health`) only `{ok}` — no version, commit or services * for strangers. Deploy scripts, container healthchecks and the watchdog send the key. */ export async function GET(req: Request) { const r = await healthReport(db, { version: process.env.NEXT_PUBLIC_PEPPA_VERSION, commit: process.env.NEXT_PUBLIC_PEPPA_COMMIT || null, }); // PEP-114: `boot` changes when the web process restarts — the domain guard recognises FORGE by it. const body = healthBody({ ...r, boot: bootId() }, req.headers.get(HEALTH_HEADER)); return Response.json(body, { status: r.ok ? 200 : 503, headers: { "Cache-Control": "no-store" } }); }