export type HealthState = { initialized: boolean; stuck: boolean; databaseDown: boolean }; /** The HTTP server and recorded calls use this same handler. */ export function statusFor(path: string | undefined, state: HealthState) { if (path === '/startupz') { return state.initialized ? 200 : 503; } if (path === '/livez') { return state.stuck ? 503 : 200; } if (path === '/readyz' || path === '/tickets') { const canServe = state.initialized && !state.stuck && !state.databaseDown; return canServe ? 200 : 503; } return 404; }