/** * Webhook Statistics API * Get webhook processing statistics */ import { NextRequest, NextResponse } from 'next/server'; import { webhookService } from '@/lib/services/webhook-service'; /** * GET /api/webhooks/stats * Get webhook statistics for the last N hours */ export async function GET(request: NextRequest) { try { const searchParams = request.nextUrl.searchParams; const hours = parseInt(searchParams.get('hours') || '24'); const stats = await webhookService.getWebhookStats(hours); return NextResponse.json({ success: true, stats, period: `${hours} hours`, }); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); console.error('[WEBHOOK STATS API] Error fetching stats:', errorMessage); return NextResponse.json( { error: 'Failed to fetch webhook stats', details: errorMessage }, { status: 500 } ); } }