@wiredcraft/health-checks
A generic health checker.
Usage
const { HealthChecker, HealthStatus } = require('@wiredcraft/health-checks');
const healthChecker = new HealthChecker();
healthChecker.addCheck(async () => {
if (Math.random() > 0.5) {
throw new Error('RandomFailure');
}
}, 'db', HealthStatus.Unhealthy.name, ['default', 'all']);
healthChecker.addCheck(async () => {
if (Math.random() > 0.5) {
throw new Error('RandomFailure');
}
}, 'external-service', HealthStatus.Degraded.name, ['all']);
const res = await healthChecker.getStatus();
const res = await healthChecker.getStatus('all');
For more details, see scenarios in test cases.