@@ -114,7 +114,7 @@ async function finishSentryProcessing(res: AugmentedResponse): Promise<void> {
114114
115115function startRequestHandlerTransactionWithRoutes (
116116 this : unknown ,
117- handler : GenericRequestHandler < SupportedResponse > ,
117+ handler : GenericRequestHandler ,
118118 framework : SupportedFramework ,
119119 routes : ServerRoute [ ] ,
120120 req : SupportedRequest ,
@@ -144,13 +144,13 @@ function startRequestHandlerTransactionWithRoutes(
144144}
145145
146146export const wrapRequestHandler = < NextFn > (
147- handler : GenericRequestHandler < SupportedResponse > ,
147+ handler : GenericRequestHandler ,
148148 framework : SupportedFramework ,
149149 readyBuildOrGetBuildFn : ServerBuild | ( ( ) => Promise < ServerBuild > | ServerBuild ) ,
150- ) : GenericRequestHandler < SupportedResponse > => {
150+ ) : GenericRequestHandler => {
151151 let routes : ServerRoute [ ] ;
152152
153- return async function ( this : unknown , req : PolymorphicRequest , res : SupportedResponse , next : NextFn ) : Promise < SupportedResponse | null > {
153+ return async function ( this : unknown , req : PolymorphicRequest , res : SupportedResponse , next : NextFn ) : Promise < FastifyReply | null > {
154154 const isExpress = framework === SupportedFramework . Express ;
155155 const isFastify = framework === SupportedFramework . Fastify ;
156156 await withIsolationScope ( async isolationScope => {
@@ -191,19 +191,19 @@ export const wrapRequestHandler = <NextFn>(
191191 // Fastify wants us to _return_ the "reply" instance
192192 // in case we are sending a response ourselves, which
193193 // we _are_ doing by means of`reply.send(data)`.
194- return isFastify ? res : null ;
194+ return isFastify ? res as FastifyReply : null ;
195195 } ;
196196} ;
197197
198198export const prepareWrapCreateRequestHandler = ( forFramework : SupportedFramework ) =>
199199 function wrapCreateRequestHandler (
200- createRequestHandler : CreateGenericRequestHandler < SupportedResponse > ,
201- ) : ( this : unknown , options : CreateRequestHandlerOptions ) => GenericRequestHandler < SupportedResponse > {
202- return function ( this : unknown , opts : CreateRequestHandlerOptions ) : GenericRequestHandler < SupportedResponse > {
203- if ( ! opts . getLoadContext ) opts [ 'getLoadContext' ] = ( ) => ( { } ) ;
200+ createRequestHandler : CreateGenericRequestHandler ,
201+ ) : ( this : unknown , options : CreateRequestHandlerOptions ) => GenericRequestHandler {
202+ return function ( this : unknown , opts : CreateRequestHandlerOptions ) : GenericRequestHandler {
203+ if ( ! ( ' getLoadContext' in opts ) ) opts [ 'getLoadContext' ] = ( ) => ( { } ) ;
204204 fill ( opts , 'getLoadContext' , wrapGetLoadContext ( forFramework ) ) ;
205205 const build = typeof opts . build === 'function' ? wrapBuildFn ( opts . build ) : instrumentBuild ( opts . build , true ) ;
206- const handler : GenericRequestHandler < SupportedResponse > = createRequestHandler . call ( this , { ...opts , build } ) ;
206+ const handler : GenericRequestHandler = createRequestHandler . call ( this , { ...opts , build } ) ;
207207 return wrapRequestHandler ( handler , forFramework , build ) ;
208208 } ;
209209 } ;
0 commit comments