Files
whatsappNucleo/server/services/debug/webhook-store.ts
josedario87 71593b25e9
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m3s
Feature: Receptor de webhooks interno para debug
- Endpoint POST /api/debug/webhook-receiver para recibir webhooks
- Almacenamiento en memoria de ultimos 100 eventos
- Endpoint GET/DELETE para consultar/limpiar eventos
- Nueva tab Webhooks en seccion Debug con polling cada 5s
2025-12-02 21:14:39 -06:00

42 lines
794 B
TypeScript

/**
* Debug Webhook Store
* Stores webhook events in memory for debugging
*/
interface WebhookEvent {
id: string
receivedAt: string
event: string
timestamp?: string
data: any
headers: Record<string, string | undefined>
}
class DebugWebhookStore {
private events: WebhookEvent[] = []
private maxEvents = 100
addEvent(event: WebhookEvent) {
this.events.unshift(event)
// Keep only the last N events
if (this.events.length > this.maxEvents) {
this.events = this.events.slice(0, this.maxEvents)
}
}
getEvents(limit: number = 50): WebhookEvent[] {
return this.events.slice(0, limit)
}
clear() {
this.events = []
}
getCount(): number {
return this.events.length
}
}
export const debugWebhookStore = new DebugWebhookStore()