Skip to main content

Quik Framework :: healthcheck

Registers healthcheck utilities and HTTP endpoints. The module sets up an IQHealthcheck feature for tracking component status and exposes readiness routes when the HTTP engine is available.

Installation

npm install @quik/healthcheck

Usage

Register and update healthcheck items:

import { getFeatureInstance, type IQHealthcheck } from '@quik/core';

const healthcheck = getFeatureInstance<IQHealthcheck>('IQHealthcheck');
healthcheck.register('database');
healthcheck.ready('database');

Register active checks with timeouts:

import { HealthcheckStatus } from '@quik/core';
import { QHealthcheck } from '@quik/healthcheck';

const healthcheck = new QHealthcheck();
healthcheck.registerCheck('cache', async () => {
// return true/false or a HealthcheckStatus
return HealthcheckStatus.OK;
}, { timeoutMs: 1000, onErrorStatus: HealthcheckStatus.DEGRADED });

await healthcheck.runChecks();

When @quik/http is present, the module registers healthcheck routes during onAfterInit.

Routes

  • GET /health returns a basic uptime payload.
  • GET /ready aggregates status from registered items and returns 503 when any item is pending, unready, degraded, or down.

API Highlights

  • QHealthcheck stores in-memory status per item.
  • QHealthcheckRoute exposes health/readiness endpoints.
  • Status helpers: ok, ready, pending, degraded, down, unready.
  • registerCheck + runChecks allow executing checks with timeouts and error classification.

Testing & Coverage

See the root instructions for details on running pnpm run test:coverage and accessing coverage artifacts.

API Reference

Generated API documentation is available in the healthcheck API section.