import { NextRequest, NextResponse } from 'next/server'; import { getMorningSummaryService } from '@/lib/services/morning-summary-service'; export async function POST(request: NextRequest) { try { const body = await request.json().catch(() => ({})); const webhookIds: number[] | undefined = body.webhookIds; const service = getMorningSummaryService(); const { summary, results } = await service.run(webhookIds); return NextResponse.json({ success: true, openCount: summary.openCount, resolvedCount: summary.resolvedCount, isWeekendWindow: summary.isWeekendWindow, results, }); } catch (error) { console.error('[POST /api/notifications/morning-summary/send]', error); return NextResponse.json({ error: String(error) }, { status: 500 }); } }