UNPKG

@experts_hub/shared

Version:

Shared DTOs, interfaces, and utilities for experts hub applications

33 lines (32 loc) 1.07 kB
import { AlertKeyComponents } from './discord-alert.interface'; export declare class RateLimiter { private readonly maxAlertsPerMinute; private alertCounts; private recentAlerts; private readonly deduplicationWindow; private readonly cleanupInterval; private cleanupTimer?; constructor(maxAlertsPerMinute?: number); canSendAlert(webhookUrl: string): boolean; recordAlert(webhookUrl: string): void; isDuplicate(alertKey: string): boolean; generateAlertKey(components: AlertKeyComponents): string; getStats(): { totalWebhooks: number; totalUniqueAlerts: number; webhookStats: Array<{ webhook: string; alertsInLastMinute: number; remainingCapacity: number; }>; }; private maskWebhookUrl; clear(): void; private startCleanup; private cleanup; destroy(): void; getDeduplicationWindow(): number; getMaxAlertsPerMinute(): number; isRateLimited(webhookUrl: string): boolean; getRemainingCapacity(webhookUrl: string): number; }