AI Toolkit
Moduleshealth

health

Self-diagnostics and per-service health checks

Overview

The health module provides configurable health checks for monitoring service status with recommendations.

No peer dependencies required.

Quick Start

import { createHealthCheck } from '@jamaalbuilds/ai-toolkit/health';

const checkHealth = createHealthCheck({
  checks: {
    database: async () => { await db.query('SELECT 1'); },
    cache: async () => { await cache.get('ping'); },
  },
});

const report = await checkHealth();
console.log(report.status); // 'healthy' | 'degraded' | 'unhealthy'

API Reference

createHealthCheck(config)

Create a health check runner.

function createHealthCheck(config: {
  checks: Record<string, () => Promise<void>>;
  timeoutMs?: number;
}): () => Promise<HealthReport>

Types

  • HealthCheckConfig — checks record mapping names to check functions, optional timeoutMs
  • HealthReport — status, checks, timestamp
  • HealthCheckResult — name, status, latencyMs, error
On this page

On this page