From 0ff9052ae83745d46b76f5549eeec1e1d6a32459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ullrich=20Sch=C3=A4fer?= Date: Fri, 27 Mar 2026 20:48:27 +0100 Subject: [PATCH] Add version (git SHA) to health endpoints Returns SENTRY_RELEASE (set at build time) as the version field, making it easy to verify which commit is deployed. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/journal/app/routes/api.health.ts | 10 +++++----- apps/planner/server.ts | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/journal/app/routes/api.health.ts b/apps/journal/app/routes/api.health.ts index cc1a396..6603a65 100644 --- a/apps/journal/app/routes/api.health.ts +++ b/apps/journal/app/routes/api.health.ts @@ -1,13 +1,13 @@ import { data } from "react-router"; import { withDb } from "@trails-cool/db"; +const version = process.env.SENTRY_RELEASE ?? "dev"; + export async function loader() { try { - await withDb(async () => { - // withDb creates a connection — if it succeeds, DB is reachable - }); - return data({ status: "ok", db: "connected" }); + await withDb(async () => {}); + return data({ status: "ok", version, db: "connected" }); } catch { - return data({ status: "degraded", db: "unreachable" }, { status: 503 }); + return data({ status: "degraded", version, db: "unreachable" }, { status: 503 }); } } diff --git a/apps/planner/server.ts b/apps/planner/server.ts index ac4e6c3..6fd8c6d 100644 --- a/apps/planner/server.ts +++ b/apps/planner/server.ts @@ -71,16 +71,18 @@ async function handleMetrics(_req: IncomingMessage, res: ServerResponse): Promis res.end(metrics); } +const version = process.env.SENTRY_RELEASE ?? "dev"; + async function handleHealth(_req: IncomingMessage, res: ServerResponse): Promise { try { const { withDb, db } = await import("@trails-cool/db"); const { sql } = await import("drizzle-orm"); await withDb(async () => { await db.execute(sql`SELECT 1`); }); res.writeHead(200, { "Content-Type": "application/json" }); - res.end(JSON.stringify({ status: "ok", db: "connected" })); + res.end(JSON.stringify({ status: "ok", version, db: "connected" })); } catch { res.writeHead(503, { "Content-Type": "application/json" }); - res.end(JSON.stringify({ status: "degraded", db: "unreachable" })); + res.end(JSON.stringify({ status: "degraded", version, db: "unreachable" })); } }