@@ -15,6 +15,14 @@ import {
1515} from '@ts-rest/core' ;
1616import * as fastify from 'fastify' ;
1717import { z } from 'zod' ;
18+ import {
19+ RawServerDefault ,
20+ RawRequestDefaultExpression ,
21+ FastifySchema ,
22+ FastifyTypeProviderDefault ,
23+ RouteGenericInterface ,
24+ RawReplyDefaultExpression ,
25+ } from 'fastify' ;
1826
1927export class RequestValidationError extends Error {
2028 constructor (
@@ -29,8 +37,21 @@ export class RequestValidationError extends Error {
2937
3038type AppRouteImplementation < T extends AppRoute > = (
3139 input : ServerInferRequest < T , fastify . FastifyRequest [ 'headers' ] > & {
32- request : fastify . FastifyRequest ;
33- reply : fastify . FastifyReply ;
40+ request : fastify . FastifyRequest <
41+ RouteGenericInterface ,
42+ RawServerDefault ,
43+ RawRequestDefaultExpression ,
44+ FastifySchema ,
45+ FastifyTypeProviderDefault ,
46+ { tsRestRoute : T }
47+ > ;
48+ reply : fastify . FastifyReply <
49+ RawServerDefault ,
50+ RawRequestDefaultExpression ,
51+ RawReplyDefaultExpression ,
52+ RouteGenericInterface ,
53+ { tsRestRoute : T }
54+ > ;
3455 appRoute : T ;
3556 } ,
3657) => Promise < ServerInferResponses < T > > ;
@@ -209,6 +230,9 @@ const registerRoute = <TAppRoute extends AppRoute>(
209230 fastify . route ( {
210231 method : appRoute . method ,
211232 url : appRoute . path ,
233+ config : {
234+ tsRestRoute : appRoute ,
235+ } ,
212236 handler : async ( request , reply ) => {
213237 const validationResults = validateRequest (
214238 request ,
0 commit comments