Feature: Receptor de webhooks interno para debug
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m3s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m3s
- 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
This commit is contained in:
32
server/api/debug/webhook-receiver.post.ts
Normal file
32
server/api/debug/webhook-receiver.post.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* POST /api/debug/webhook-receiver
|
||||
* Internal endpoint to receive webhooks for debugging
|
||||
* Stores events in memory and emits via SSE
|
||||
*/
|
||||
import { debugWebhookStore } from '../../services/debug/webhook-store'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event)
|
||||
const headers = getHeaders(event)
|
||||
|
||||
const webhookEvent = {
|
||||
id: crypto.randomUUID(),
|
||||
receivedAt: new Date().toISOString(),
|
||||
event: body.event || 'unknown',
|
||||
timestamp: body.timestamp,
|
||||
data: body.data || body,
|
||||
headers: {
|
||||
'x-webhook-event': headers['x-webhook-event'],
|
||||
'x-webhook-timestamp': headers['x-webhook-timestamp'],
|
||||
'x-webhook-signature': headers['x-webhook-signature'],
|
||||
'content-type': headers['content-type'],
|
||||
}
|
||||
}
|
||||
|
||||
// Store the event
|
||||
debugWebhookStore.addEvent(webhookEvent)
|
||||
|
||||
console.log(`[Debug Webhook] Received event: ${webhookEvent.event}`)
|
||||
|
||||
return { success: true, message: 'Event received' }
|
||||
})
|
||||
Reference in New Issue
Block a user