@@ -8,6 +8,7 @@ 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" ;
11
12
12
13
/**
13
14
* Builds metadata from the given metadata arguments.
@@ -79,22 +80,54 @@ export class MetadataBuilder {
79
80
} ) ;
80
81
}
81
82
83
+ // /**
84
+ // * Creates action metadatas.
85
+ // */
86
+ // protected createActions(controller: ControllerMetadata): ActionMetadata[] {
87
+ // return getMetadataArgsStorage()
88
+ // .filterActionsWithTarget(controller.target)
89
+ // .map(actionArgs => {
90
+ // const action = new ActionMetadata(controller, actionArgs, this.options);
91
+ // action.params = this.createParams(action);
92
+ // action.uses = this.createActionUses(action);
93
+ // action.interceptors = this.createActionInterceptorUses(action);
94
+ // action.build(this.createActionResponseHandlers(action));
95
+ // return action;
96
+ // });
97
+ // }
98
+
82
99
/**
83
100
* Creates action metadatas.
84
101
*/
85
102
protected createActions ( controller : ControllerMetadata ) : ActionMetadata [ ] {
86
- return getMetadataArgsStorage ( )
87
- . filterActionsWithTarget ( controller . target )
88
- . map ( actionArgs => {
89
- const action = new ActionMetadata ( controller , actionArgs , this . options ) ;
90
- action . params = this . createParams ( action ) ;
91
- action . uses = this . createActionUses ( action ) ;
92
- action . interceptors = this . createActionInterceptorUses ( action ) ;
93
- action . build ( this . createActionResponseHandlers ( action ) ) ;
94
- return action ;
95
- } ) ;
103
+ let target = controller . target ;
104
+ let actionsWithTarget : ActionMetadataArgs [ ] = [ ] ;
105
+
106
+ while ( target ) {
107
+ actionsWithTarget . push (
108
+ ...getMetadataArgsStorage ( )
109
+ . filterActionsWithTarget ( target )
110
+ . filter ( action => {
111
+ return actionsWithTarget
112
+ . map ( a => a . method )
113
+ . indexOf ( action . method ) === - 1 ;
114
+ } )
115
+ ) ;
116
+ target = Object . getPrototypeOf ( target ) ;
117
+ }
118
+
119
+ return actionsWithTarget
120
+ . map ( actionArgs => {
121
+ const action = new ActionMetadata ( controller , actionArgs , this . options ) ;
122
+ action . params = this . createParams ( action ) ;
123
+ action . uses = this . createActionUses ( action ) ;
124
+ action . interceptors = this . createActionInterceptorUses ( action ) ;
125
+ action . build ( this . createActionResponseHandlers ( action ) ) ;
126
+ return action ;
127
+ } ) ;
96
128
}
97
129
130
+
98
131
/**
99
132
* Creates param metadatas.
100
133
*/
@@ -111,7 +144,7 @@ export class MetadataBuilder {
111
144
let options = this . options . defaults && this . options . defaults . paramOptions ;
112
145
if ( ! options )
113
146
return paramArgs ;
114
-
147
+
115
148
if ( paramArgs . required === undefined )
116
149
paramArgs . required = options . required || false ;
117
150
0 commit comments