@j03fr0st/pubg-ts
Version:
A comprehensive TypeScript wrapper for the PUBG API
112 lines • 2.85 kB
TypeScript
import { type SystemHealth } from './monitoring';
export interface HealthCheckResult {
status: 'pass' | 'fail' | 'warn';
componentId: string;
componentType: string;
observedValue?: any;
observedUnit?: string;
output?: string;
time: string;
duration: number;
}
export interface DetailedHealthReport {
status: 'pass' | 'fail' | 'warn';
version: string;
releaseId: string;
description: string;
checks: Record<string, HealthCheckResult>;
links: {
self: string;
metrics?: string;
logs?: string;
};
serviceId: string;
timestamp: string;
uptime: number;
}
/**
* Comprehensive health check system following RFC 7807 and health check standards
*
* Provides detailed health monitoring for:
* - System resources (memory, CPU, disk)
* - External dependencies (PUBG API, network)
* - Internal components (cache, rate limiter)
* - Application-specific checks
*
* @example
* ```typescript
* const healthChecker = new HealthChecker();
*
* // Get simple health status
* const isHealthy = await healthChecker.isHealthy();
*
* // Get detailed health report
* const report = await healthChecker.getDetailedHealth();
*
* // Add custom health check
* healthChecker.addCustomCheck('database', async () => {
* try {
* await database.ping();
* return { status: 'pass', output: 'Database connection successful' };
* } catch (error) {
* return { status: 'fail', output: `Database error: ${error.message}` };
* }
* });
* ```
*/
export declare class HealthChecker {
private customChecks;
private startTime;
private version;
private serviceId;
constructor(options?: {
version?: string;
serviceId?: string;
});
/**
* Simple health check - returns boolean
*/
isHealthy(): Promise<boolean>;
/**
* Get basic system health
*/
getHealth(): Promise<SystemHealth>;
/**
* Get comprehensive health report with all checks
*/
getDetailedHealth(): Promise<DetailedHealthReport>;
/**
* Add a custom health check
*/
addCustomCheck(name: string, check: () => Promise<Partial<HealthCheckResult>>): void;
/**
* Remove a custom health check
*/
removeCustomCheck(name: string): void;
/**
* Check memory usage
*/
private checkMemory;
/**
* Check system uptime
*/
private checkUptime;
/**
* Check PUBG API connectivity
*/
private checkPubgApi;
/**
* Check Node.js event loop lag
*/
private checkEventLoop;
/**
* Check overall process health
*/
private checkProcessHealth;
/**
* Run a custom health check
*/
private runCustomCheck;
}
export declare const healthChecker: HealthChecker;
//# sourceMappingURL=health-check.d.ts.map