@@ -8,6 +8,7 @@ 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" ;
1112
1213/**
1314 * Builds metadata from the given metadata arguments.
@@ -79,22 +80,54 @@ export class MetadataBuilder {
7980 } ) ;
8081 }
8182
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+
8299 /**
83100 * Creates action metadatas.
84101 */
85102 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+ } ) ;
96128 }
97129
130+
98131 /**
99132 * Creates param metadatas.
100133 */
@@ -111,7 +144,7 @@ export class MetadataBuilder {
111144 let options = this . options . defaults && this . options . defaults . paramOptions ;
112145 if ( ! options )
113146 return paramArgs ;
114-
147+
115148 if ( paramArgs . required === undefined )
116149 paramArgs . required = options . required || false ;
117150
0 commit comments