Interface for components that support health checks.
class DatabaseHealthCheck implements HealthCheck { async check(): Promise<HealthCheckResult> { try { await this.database.ping(); return { status: HealthStatus.UP, message: 'Database connection healthy', details: { latency: '5ms' } }; } catch (error) { return { status: HealthStatus.DOWN, message: 'Database connection failed', details: { error: error.message } }; } }} Copy
class DatabaseHealthCheck implements HealthCheck { async check(): Promise<HealthCheckResult> { try { await this.database.ping(); return { status: HealthStatus.UP, message: 'Database connection healthy', details: { latency: '5ms' } }; } catch (error) { return { status: HealthStatus.DOWN, message: 'Database connection failed', details: { error: error.message } }; } }}
Performs a health check.
The result of the health check
const result = await healthCheck.check();if (result.status === HealthStatus.UP) { console.log('Service is healthy');} Copy
const result = await healthCheck.check();if (result.status === HealthStatus.UP) { console.log('Service is healthy');}
Interface for components that support health checks.
Example