@@ -12,10 +12,11 @@ import { createLogger } from "@sourcebot/shared";
1212import { randomUUID } from "crypto" ;
1313import { StatusCodes } from "http-status-codes" ;
1414import { headers } from "next/headers" ;
15- import { NextResponse } from "next/server" ;
15+ import { NextRequest , NextResponse } from "next/server" ;
1616import { z } from "zod" ;
1717import { createMessageStream } from "../route" ;
1818import { InferUIMessageChunk , UITools , UIDataTypes , UIMessage } from "ai" ;
19+ import { apiHandler } from "@/lib/apiHandler" ;
1920
2021const logger = createLogger ( 'chat-blocking-api' ) ;
2122
@@ -51,7 +52,7 @@ interface BlockingChatResponse {
5152 * The chat session is persisted to the database, allowing users to view the full
5253 * conversation (including tool calls and reasoning) in the web UI.
5354 */
54- export async function POST ( request : Request ) {
55+ export const POST = apiHandler ( async ( request : NextRequest ) => {
5556 const requestBody = await request . json ( ) ;
5657 const parsed = await blockingChatRequestSchema . safeParseAsync ( requestBody ) ;
5758
@@ -193,7 +194,7 @@ export async function POST(request: Request) {
193194 }
194195
195196 return NextResponse . json ( response ) ;
196- }
197+ } ) ;
197198
198199const blockStreamUntilFinish = async < T extends UIMessage < unknown , UIDataTypes , UITools > > ( stream : ReadableStream < InferUIMessageChunk < T > > ) => {
199200 const reader = stream . getReader ( ) ;
0 commit comments