@@ -8,7 +8,6 @@ import { ResponseHandlerMetadata } from '../metadata/ResponseHandleMetadata';
8
8
import { RoutingControllersOptions } from '../RoutingControllersOptions' ;
9
9
import { UseMetadata } from '../metadata/UseMetadata' ;
10
10
import { getMetadataArgsStorage } from '../index' ;
11
- import { ActionMetadataArgs } from '../metadata/args/ActionMetadataArgs' ;
12
11
13
12
/**
14
13
* Builds metadata from the given metadata arguments.
@@ -92,33 +91,25 @@ export class MetadataBuilder {
92
91
* Creates action metadatas.
93
92
*/
94
93
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 ) ;
102
109
} ) ;
103
-
104
- actions . forEach ( a => {
105
- a . target = controller . target ;
106
-
107
- actionsWithTarget . push ( a ) ;
108
- } ) ;
109
-
110
- target = Object . getPrototypeOf ( target ) ;
111
110
}
112
111
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 ;
122
113
}
123
114
124
115
/**
0 commit comments