Responses and HTTP
Rollup status
Overall HealthResponse.status is computed from all check results for that probe:
- Any
fail→fail(unless remapped byonFail.treatAson that check). - Else any
degraded→degraded. - Else
ok.
Override with rollup.computeStatus(results) for custom rules.
HTTP status
Response status (HTTP code) is derived from the rolled-up health status and your config:
- Any check with
status === "fail"andonFail.httpStatusset → that value is returned (first matching check in config order wins among failed checks with a custom status). - Else if rollup is
fail:defaults.onFail.httpStatusor 503. - Else if rollup is
degraded:defaults.onDegraded.httpStatusor 200. - Else 200.
onFail.treatAs changes the check status used for rollup and the JSON/text body; combine with onFail.httpStatus or defaults when you need a specific HTTP code.
Output
output on the root config:
format:"json"(default) or"text".- JSON:
Content-Type: application/json, body isJSON.stringifyofHealthResponse. - Text:
Content-Type: text/plain, human-readable lines (status:, then each check with latency and optional error).
- JSON:
exposeError: Default true. If false, theerrorfield is omitted from each check in the payload.
Public API overview
Runtime
createHealthKit(config)→HealthKitHealthKit:start(),stop(),handleRequest(req),handleLiveness(),handleReadiness()
Types
HealthkitConfig,CheckConfig,HealthAdapter,AdapterResult,CheckResult,HealthResponseCheckStatus,CheckType,RollupConfig,OutputConfig,DefaultsConfigAgnosticRequest,AgnosticResponse
The canonical type definitions and any future additions live in the healthzkit package under packages/healthzkit in this monorepo.