@experts_hub/shared
Version:
Shared DTOs, interfaces, and utilities for experts hub applications
40 lines (39 loc) • 1.68 kB
TypeScript
import { DiscordAlertOptions, DiscordWebhookConfig } from './discord-alert.interface';
import { RateLimiter } from './rate-limiter';
export declare class DiscordAlertService {
private readonly rateLimiter;
private readonly config;
private alertsSent;
private alertsFailed;
constructor(config: DiscordWebhookConfig);
sendAlert(options: DiscordAlertOptions): Promise<void>;
sendCriticalError(error: Error, context?: Record<string, any>): Promise<void>;
sendDatabaseError(message: string, context?: Record<string, any>): Promise<void>;
sendSecurityAlert(title: string, description: string, context?: Record<string, any>): Promise<void>;
sendPaymentError(message: string, context?: Record<string, any>): Promise<void>;
sendBusinessEvent(title: string, description: string, context?: Record<string, any>): Promise<void>;
sendPerformanceWarning(title: string, description: string, metrics?: Record<string, any>): Promise<void>;
private getWebhookUrl;
private sendToWebhook;
private httpPost;
private getHostname;
private log;
private logError;
getStats(): {
alertsSent: number;
alertsFailed: number;
successRate: number;
rateLimiterStats: ReturnType<RateLimiter['getStats']>;
};
resetStats(): void;
isConfigured(): boolean;
getConfig(): Omit<Required<DiscordWebhookConfig>, 'errorWebhookUrl' | 'securityWebhookUrl' | 'businessWebhookUrl' | 'performanceWebhookUrl'> & {
webhooksConfigured: {
error: boolean;
security: boolean;
business: boolean;
performance: boolean;
};
};
destroy(): void;
}