@rtorcato/api-health
v1.0.1
Published
Framework-agnostic liveness/readiness health-check registry for Node API projects.
Maintainers
Readme
@rtorcato/api-health
Framework-agnostic liveness/readiness health-check registry for Node API
projects. Register readiness checks (DB pings, broker connections, …) and run
them from a probe endpoint — or drop in the Express or Hono adapter for
ready-made /healthz and /readyz handlers.
Install
pnpm add @rtorcato/api-healthUsage
import { createHealthRegistry } from '@rtorcato/api-health'
const health = createHealthRegistry()
// A check reports healthy by returning/resolving, unhealthy by throwing.
health.register('db', async () => {
await db.query('SELECT 1')
})
const report = await health.run()
// { status: 'unhealthy', checks: { db: { status: 'healthy' }, ... } }- Liveness — "is the process up?" Always
200; runs no checks, so a slow dependency never triggers a needless restart. - Readiness — "can I serve traffic?" Runs every registered check;
200when all pass,503when any fail, with a per-check report as the body.
Checks run concurrently on each run(), and there is no per-check
timeout — wrap a check in your own timeout race if it must fail fast.
Framework adapters
Full guide: api-health.
License
MIT
