Health Checks
healthCheck()
Section titled “healthCheck()”Add a health check endpoint for monitoring and DevOps:
app.healthCheck(); // default: GET /healthapp.healthCheck("/status"); // custom pathResponse
Section titled “Response”{ "status": "OK", "uptime": 123.456, "pid": 12345, "timestamp": "2025-01-01T00:00:00.000Z"}With Readiness Check
Section titled “With Readiness Check”app.healthCheck({ readinessCheck: async () => { const dbOk = await checkDatabase(); return { ok: dbOk }; }});Returns 200 OK when healthy, 503 Service Unavailable if the readiness check fails.
Options
Section titled “Options”| Option | Type | Description |
|---|---|---|
path | string | Custom endpoint path (default: /health) |
readinessCheck | Function | Async function returning { ok: boolean } |
replace | boolean | Replace existing health endpoint (default: false) |
include | Object | Toggle response fields: uptime, pid, env, timestamp, metrics |