File tree Expand file tree Collapse file tree
libs/ts-rest/next/src/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @ts-rest/next ' : minor
3+ ---
4+
5+ Provide access to req and res from Next.js adapter
Original file line number Diff line number Diff line change @@ -21,13 +21,17 @@ import {
2121type RouteToQueryFunctionImplementation < T extends AppRouteQuery > = ( args : {
2222 params : PathParams < T > ;
2323 query : ZodInferOrType < T [ 'query' ] > ;
24+ req : NextApiRequest ;
25+ res : NextApiResponse ;
2426} ) => Promise < ApiRouteResponse < T [ 'responses' ] > > ;
2527
2628type RouteToMutationFunctionImplementation < T extends AppRouteMutation > =
2729 ( args : {
2830 params : PathParams < T > ;
2931 body : ZodInferOrType < T [ 'body' ] > ;
3032 query : ZodInferOrType < T [ 'query' ] > ;
33+ req : NextApiRequest ;
34+ res : NextApiResponse ;
3135 } ) => Promise < ApiRouteResponse < T [ 'responses' ] > > ;
3236
3337type RouteToFunctionImplementation < T extends AppRoute > = T extends AppRouteQuery
@@ -229,6 +233,8 @@ export const createNextRouter =
229233 body : req . body ,
230234 query : req . query ,
231235 params : pathParams ,
236+ req,
237+ res,
232238 } ) ;
233239
234240 res . status ( Number ( status ) ) . json ( body ) ;
You can’t perform that action at this time.
0 commit comments