11import type { SchemaDef } from '@zenstackhq/orm/schema' ;
2- import { NextRequest , NextResponse } from 'next/server' ;
2+ import type { NextRequest } from 'next/server' ;
33import type { AppRouteRequestHandlerOptions } from '.' ;
44import { logInternalError } from '../common' ;
55
@@ -13,11 +13,11 @@ type Context = { params: Promise<{ path: string[] }> };
1313 */
1414export default function factory < Schema extends SchemaDef > (
1515 options : AppRouteRequestHandlerOptions < Schema > ,
16- ) : ( req : NextRequest , context : Context ) => Promise < NextResponse > {
16+ ) : ( req : NextRequest , context : Context ) => Promise < Response > {
1717 return async ( req : NextRequest , context : Context ) => {
1818 const client = await options . getClient ( req ) ;
1919 if ( ! client ) {
20- return NextResponse . json ( { message : 'unable to get ZenStackClient from request context' } , { status : 500 } ) ;
20+ return Response . json ( { message : 'unable to get ZenStackClient from request context' } , { status : 500 } ) ;
2121 }
2222
2323 let params : Awaited < Context [ 'params' ] > ;
@@ -27,11 +27,11 @@ export default function factory<Schema extends SchemaDef>(
2727 try {
2828 params = await context . params ;
2929 } catch {
30- return NextResponse . json ( { message : 'Failed to resolve request parameters' } , { status : 500 } ) ;
30+ return Response . json ( { message : 'Failed to resolve request parameters' } , { status : 500 } ) ;
3131 }
3232
3333 if ( ! params . path ) {
34- return NextResponse . json (
34+ return Response . json (
3535 { message : 'missing path parameter' } ,
3636 {
3737 status : 400 ,
@@ -57,10 +57,10 @@ export default function factory<Schema extends SchemaDef>(
5757 requestBody,
5858 client,
5959 } ) ;
60- return NextResponse . json ( r . body , { status : r . status } ) ;
60+ return Response . json ( r . body , { status : r . status } ) ;
6161 } catch ( err ) {
6262 logInternalError ( options . apiHandler . log , err ) ;
63- return NextResponse . json ( { message : 'An internal server error occurred' } , { status : 500 } ) ;
63+ return Response . json ( { message : 'An internal server error occurred' } , { status : 500 } ) ;
6464 }
6565 } ;
6666}
0 commit comments