@@ -87,33 +87,21 @@ export class ExpressDriver extends BaseDriver implements Driver {
87
87
88
88
// middlewares required for this action
89
89
const defaultMiddlewares : any [ ] = [ ] ;
90
+
90
91
if ( actionMetadata . isBodyUsed ) {
91
92
if ( actionMetadata . isJsonTyped ) {
92
93
defaultMiddlewares . push ( this . loadBodyParser ( ) . json ( actionMetadata . bodyExtraOptions ) ) ;
93
94
} else {
94
95
defaultMiddlewares . push ( this . loadBodyParser ( ) . text ( actionMetadata . bodyExtraOptions ) ) ;
95
96
}
96
97
}
97
- if ( actionMetadata . isFileUsed || actionMetadata . isFilesUsed ) {
98
- const multer = this . loadMulter ( ) ;
99
- actionMetadata . params
100
- . filter ( param => param . type === "file" )
101
- . forEach ( param => {
102
- defaultMiddlewares . push ( multer ( param . extraOptions ) . single ( param . name ) ) ;
103
- } ) ;
104
- actionMetadata . params
105
- . filter ( param => param . type === "files" )
106
- . forEach ( param => {
107
- defaultMiddlewares . push ( multer ( param . extraOptions ) . array ( param . name ) ) ;
108
- } ) ;
109
- }
110
98
111
99
if ( actionMetadata . isAuthorizedUsed ) {
112
100
defaultMiddlewares . push ( ( request : any , response : any , next : Function ) => {
113
101
if ( ! this . authorizationChecker )
114
102
throw new AuthorizationCheckerNotDefinedError ( ) ;
115
103
116
- const action : Action = { request, response, next} ;
104
+ const action : Action = { request, response, next } ;
117
105
const checkResult = this . authorizationChecker ( action , actionMetadata . authorizedRoles ) ;
118
106
119
107
const handleError = ( result : any ) => {
@@ -135,6 +123,20 @@ export class ExpressDriver extends BaseDriver implements Driver {
135
123
} ) ;
136
124
}
137
125
126
+ if ( actionMetadata . isFileUsed || actionMetadata . isFilesUsed ) {
127
+ const multer = this . loadMulter ( ) ;
128
+ actionMetadata . params
129
+ . filter ( param => param . type === "file" )
130
+ . forEach ( param => {
131
+ defaultMiddlewares . push ( multer ( param . extraOptions ) . single ( param . name ) ) ;
132
+ } ) ;
133
+ actionMetadata . params
134
+ . filter ( param => param . type === "files" )
135
+ . forEach ( param => {
136
+ defaultMiddlewares . push ( multer ( param . extraOptions ) . array ( param . name ) ) ;
137
+ } ) ;
138
+ }
139
+
138
140
// user used middlewares
139
141
const uses = [ ...actionMetadata . controllerMetadata . uses , ...actionMetadata . uses ] ;
140
142
const beforeMiddlewares = this . prepareMiddlewares ( uses . filter ( use => ! use . afterAction ) ) ;
0 commit comments