wulf-pulse/app/api/webhooks/status/route.ts

30 lines
940 B
TypeScript

/**
* Webhook Status API
* GET /api/webhooks/status — Show registered webhooks and their Autotask status
*/
import { NextResponse } from 'next/server';
import { AutotaskWebhookManager } from '@/lib/services/autotask-webhook-manager';
import { webhookService } from '@/lib/services/webhook-service';
export async function GET() {
try {
const manager = new AutotaskWebhookManager();
const [registrationStatus, stats] = await Promise.all([
manager.getStatus(),
webhookService.getWebhookStats(24),
]);
return NextResponse.json({
success: true,
registrations: registrationStatus,
stats,
webhookUrl: `${process.env.WEBHOOK_BASE_URL || ''}/api/webhooks/autotask`,
});
} catch (error) {
const msg = error instanceof Error ? error.message : String(error);
console.error('[WEBHOOK-STATUS] Error:', msg);
return NextResponse.json({ error: msg }, { status: 500 });
}
}