@@ -83,7 +83,7 @@ export class RouterExecutionContext {
8383 fnHandleResponse,
8484 paramtypes,
8585 getParamsMetadata,
86- } = this . getMetadata ( instance , callback , methodName , module , requestMethod ) ;
86+ } = this . getMetadata ( instance , callback , methodName , module ) ;
8787 const paramsOptions = this . contextUtils . mergeParamsMetatypes (
8888 getParamsMetadata ( module , contextId , inquirerId ) ,
8989 paramtypes ,
@@ -131,6 +131,14 @@ export class RouterExecutionContext {
131131 const args = this . contextUtils . createNullArray ( argsLength ) ;
132132 fnCanActivate && ( await fnCanActivate ( [ req , res ] ) ) ;
133133
134+ const httpCode = this . reflectHttpStatusCode ( callback ) ;
135+
136+ const httpStatusCode = httpCode
137+ ? httpCode
138+ : this . responseController . getStatusByMethod ( requestMethod ) ;
139+
140+ this . responseController . status ( res , httpStatusCode ) ;
141+
134142 const result = await this . interceptorsConsumer . intercept (
135143 interceptors ,
136144 [ req , res ] ,
@@ -146,8 +154,7 @@ export class RouterExecutionContext {
146154 instance : Controller ,
147155 callback : ( ...args : any [ ] ) => any ,
148156 methodName : string ,
149- module : string ,
150- requestMethod : RequestMethod ,
157+ module : string
151158 ) : HandlerMetadata {
152159 const cacheMetadata = this . handlerMetadataStorage . get ( instance , methodName ) ;
153160 if ( cacheMetadata ) {
@@ -165,7 +172,6 @@ export class RouterExecutionContext {
165172 instance ,
166173 methodName ,
167174 ) ;
168- const httpCode = this . reflectHttpStatusCode ( callback ) ;
169175 const getParamsMetadata = (
170176 moduleKey : string ,
171177 contextId = STATIC_CONTEXT ,
@@ -184,14 +190,10 @@ export class RouterExecutionContext {
184190 ( { type } ) =>
185191 type === RouteParamtypes . RESPONSE || type === RouteParamtypes . NEXT ,
186192 ) ;
187- const httpStatusCode = httpCode
188- ? httpCode
189- : this . responseController . getStatusByMethod ( requestMethod ) ;
190193
191194 const fnHandleResponse = this . createHandleResponseFn (
192195 callback ,
193- isResponseHandled ,
194- httpStatusCode ,
196+ isResponseHandled
195197 ) ;
196198 const handlerMetadata : HandlerMetadata = {
197199 argsLength,
@@ -341,8 +343,7 @@ export class RouterExecutionContext {
341343
342344 public createHandleResponseFn (
343345 callback : ( ...args : any [ ] ) => any ,
344- isResponseHandled : boolean ,
345- httpStatusCode : number ,
346+ isResponseHandled : boolean
346347 ) {
347348 const renderTemplate = this . reflectRenderTemplate ( callback ) ;
348349 const responseHeaders = this . reflectResponseHeaders ( callback ) ;
@@ -358,10 +359,9 @@ export class RouterExecutionContext {
358359 return async < TResult , TResponse > ( result : TResult , res : TResponse ) => {
359360 hasCustomHeaders &&
360361 this . responseController . setHeaders ( res , responseHeaders ) ;
361-
362362 result = await this . responseController . transformToResult ( result ) ;
363363 ! isResponseHandled &&
364- ( await this . responseController . apply ( result , res , httpStatusCode ) ) ;
364+ ( await this . responseController . apply ( result , res ) ) ;
365365 } ;
366366 }
367367}
0 commit comments