| 1 | import { NextRequest, NextResponse } from 'next/server'; |
| 2 | import { handleMessage } from '@/lib/router'; |
| 3 | |
| 4 | export const runtime = 'nodejs'; |
| 5 | export const dynamic = 'force-dynamic'; |
| 6 | export const maxDuration = 300; |
| 7 | |
| 8 | export async function POST(req: NextRequest) { |
| 9 | const { channelId, text } = await req.json(); |
| 10 | if (!channelId || !text) return NextResponse.json({ error: 'channelId and text required' }, { status: 400 }); |
| 11 | try { |
| 12 | const produced = await handleMessage(channelId, String(text)); |
| 13 | return NextResponse.json({ messages: produced }); |
| 14 | } catch (e) { |
| 15 | return NextResponse.json({ error: (e as Error).message }, { status: 500 }); |
| 16 | } |
| 17 | } |