feat(health): report build version
This commit is contained in:
@@ -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,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",
|
||||
|
||||
Reference in New Issue
Block a user