@traceos/health-check
v1.0.2
Published
Production-grade health check framework for any runtime (Cloudflare Workers, Node.js, Express, etc)
Downloads
51
Maintainers
Readme
@sygnl/health-check
Production-ready health check framework with status aggregation and dependency tracking.
Install
npm install @sygnl/health-checkQuick Start
import { HealthChecker } from '@sygnl/health-check';
const health = new HealthChecker();
// Register checks
health.register('database', async () => {
const connected = await db.ping();
return { healthy: connected };
});
health.register('redis', async () => {
const ok = await redis.ping();
return { healthy: ok };
});
// Run all checks
const result = await health.check();
console.log(result.status); // 'healthy' | 'degraded' | 'unhealthy'Features
- Parallel check execution
- Status aggregation (healthy, degraded, unhealthy)
- Critical vs non-critical checks
- Built-in common checks (HTTP, exists, condition)
- Response time tracking
- Type-safe with TypeScript
API
HealthChecker
const health = new HealthChecker({
timeout: 5000, // Default timeout per check (ms)
parallel: true // Run checks in parallel
});
// Register a check
health.register('api', async () => ({
healthy: true,
message: 'API is responsive'
}));
// Run all checks
const result = await health.check();
// Run specific checks
const result = await health.check(['database', 'redis']);Common Checks
import { checkHttp, checkExists, checkCondition } from '@sygnl/health-check';
// HTTP endpoint check
health.register('api', checkHttp('https://api.example.com/health'));
// Check value exists
health.register('config', checkExists(process.env.API_KEY, 'API key missing'));
// Custom condition
health.register('memory', checkCondition(
() => process.memoryUsage().heapUsed < 500_000_000,
'Memory usage too high'
));Result Format
{
status: 'healthy', // Overall status
timestamp: 1234567890, // Unix timestamp
checks: {
database: {
status: 'healthy',
responseTime: 45, // ms
message: 'Connected'
},
redis: {
status: 'healthy',
responseTime: 12
}
}
}License
Apache-2.0
Copyright 2026 Edge Foundry, Inc.
