@@ -8,7 +8,6 @@ import { ResponseHandlerMetadata } from '../metadata/ResponseHandleMetadata';
88import { RoutingControllersOptions } from '../RoutingControllersOptions' ;
99import { UseMetadata } from '../metadata/UseMetadata' ;
1010import { getMetadataArgsStorage } from '../index' ;
11- import { ActionMetadataArgs } from '../metadata/args/ActionMetadataArgs' ;
1211
1312/**
1413 * Builds metadata from the given metadata arguments.
@@ -92,33 +91,25 @@ export class MetadataBuilder {
9291 * Creates action metadatas.
9392 */
9493 protected createActions ( controller : ControllerMetadata ) : ActionMetadata [ ] {
95- let target = controller . target ;
96- const actionsWithTarget : ActionMetadataArgs [ ] = [ ] ;
97- while ( target ) {
98- const actions = getMetadataArgsStorage ( )
99- . filterActionsWithTarget ( target )
100- . filter ( action => {
101- return actionsWithTarget . map ( a => a . method ) . indexOf ( action . method ) === - 1 ;
94+ const actionsWithTarget : ActionMetadata [ ] = [ ] ;
95+ for ( let target = controller . target ; target ; target = Object . getPrototypeOf ( target ) ) {
96+ const actions = getMetadataArgsStorage ( ) . filterActionsWithTarget ( target ) ;
97+ const methods = actionsWithTarget . map ( a => a . method ) ;
98+ actions
99+ . filter ( ( { method } ) => ! methods . includes ( method ) )
100+ . forEach ( actionArgs => {
101+ const action = new ActionMetadata ( controller , { ...actionArgs , target : controller . target } , this . options ) ;
102+ action . options = { ...controller . options , ...actionArgs . options } ;
103+ action . params = this . createParams ( action ) ;
104+ action . uses = this . createActionUses ( action ) ;
105+ action . interceptors = this . createActionInterceptorUses ( action ) ;
106+ action . build ( this . createActionResponseHandlers ( action ) ) ;
107+
108+ actionsWithTarget . push ( action ) ;
102109 } ) ;
103-
104- actions . forEach ( a => {
105- a . target = controller . target ;
106-
107- actionsWithTarget . push ( a ) ;
108- } ) ;
109-
110- target = Object . getPrototypeOf ( target ) ;
111110 }
112111
113- return actionsWithTarget . map ( actionArgs => {
114- const action = new ActionMetadata ( controller , actionArgs , this . options ) ;
115- action . options = { ...controller . options , ...actionArgs . options } ;
116- action . params = this . createParams ( action ) ;
117- action . uses = this . createActionUses ( action ) ;
118- action . interceptors = this . createActionInterceptorUses ( action ) ;
119- action . build ( this . createActionResponseHandlers ( action ) ) ;
120- return action ;
121- } ) ;
112+ return actionsWithTarget ;
122113 }
123114
124115 /**
0 commit comments