feat(health): report build version
CI / validate (push) Successful in 6m24s
Release / release (push) Successful in 8m19s

This commit is contained in:
dmg
2026-08-08 11:06:06 -04:00
parent 56cbecc3f7
commit 168a7a2c36
5 changed files with 22 additions and 7 deletions
+13 -3
View File
@@ -1,12 +1,22 @@
import { describe, expect, it } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import { GET } from "./route";
describe("health endpoint", () => {
it("reports process readiness without requiring external services", async () => {
afterEach(() => vi.unstubAllEnvs());
it("reports process readiness and the immutable build version without requiring external services", async () => {
vi.stubEnv("APP_VERSION", "1.19.0");
const response = GET();
expect(response.status).toBe(200);
expect(response.headers.get("cache-control")).toBe("no-store");
expect(await response.json()).toEqual({ status: "ok" });
expect(await response.json()).toEqual({ status: "ok", version: "1.19.0" });
});
it("reports a development version when no build version is supplied", async () => {
vi.stubEnv("APP_VERSION", "");
expect(await GET().json()).toEqual({ status: "ok", version: "development" });
});
});
+1 -1
View File
@@ -1,6 +1,6 @@
export function GET(): Response {
return Response.json(
{ status: "ok" },
{ status: "ok", version: process.env.APP_VERSION?.trim() || "development" },
{
headers: {
"Cache-Control": "no-store",