import { readFileSync } from "node:fs"; import path from "node:path"; import { APP_VERSION } from "@/lib/version"; export const runtime = "nodejs"; export const dynamic = "force-dynamic"; /** * Deploy health check: reports which release is running. The deploy script * writes `release.json` next to the server (in the standalone root) and polls * this route after switching `current`; a mismatch or an unreachable server * triggers the automatic rollback. * * In a dev checkout there is no release.json — the route answers with the * commit baked into the environment, or "dev". */ export async function GET() { let release: { commit?: string; short?: string; builtAt?: string; release?: string } | null = null; try { release = JSON.parse(readFileSync(path.join(process.cwd(), "release.json"), "utf8")); } catch { release = null; } const commit = release?.commit ?? process.env.FREEZMO_COMMIT ?? "dev"; return Response.json( { ok: true, version: APP_VERSION, commit, short: release?.short ?? commit.slice(0, 7), builtAt: release?.builtAt ?? null, release: release?.release ?? null, dev: commit === "dev", uptimeSeconds: Math.round(process.uptime()), }, { headers: { "Cache-Control": "no-store" } }, ); }