@@ -26,32 +26,33 @@ module.exports = function(options) {
2626 getObjectPath ( getObjectPath ( [ 'authorizer' , 'arn' ] , e ) || '' , options . authorizers ) ||
2727 getObjectPath ( getObjectPath ( [ 'authorizer' , 'name' ] , e ) || '' , slsHandlers )
2828 ) ;
29+ const callbacks = [ decorateLambdaReqCallback ( ) ] ;
30+ if ( authorizerFunction ) {
31+ callbacks . push ( authorizerValidationCallback (
32+ authSource ,
33+ authValidatorExp ? new RegExp ( authValidatorExp ) : null ,
34+ {
35+ regionId : 'express' ,
36+ accountId : 'serverlessify' ,
37+ apiId : `${ slsConf . service } -${ funcId } ` ,
38+ }
39+ ) ) ;
40+ callbacks . push ( authorizerCheckCallback (
41+ authorizerFunction ,
42+ options . setCacheEntry ,
43+ options . getCacheEntry ,
44+ authCacheTtl
45+ ) ) ;
46+ }
47+ if ( e . cors ) {
48+ callbacks . push ( decorateAddCORSCallback ( ) ) ;
49+ }
50+ callbacks . push ( executeLambdaCallback ( func ) ) ;
2951 options . html (
3052 e . method . toLowerCase ( ) ,
3153 `/${ e . path . replace ( / \{ ( .+ ?) \} / g, ':$1' ) } ` ,
32- [
33- decorateLambdaReqCallback ( ) ,
34- ...( authorizerFunction ? [
35- authorizerValidationCallback (
36- authSource ,
37- authValidatorExp ? new RegExp ( authValidatorExp ) : null ,
38- {
39- regionId : 'express' ,
40- accountId : 'serverlessify' ,
41- apiId : `${ slsConf . service } -${ funcId } ` ,
42- }
43- ) ,
44- authorizerCheckCallback (
45- authorizerFunction ,
46- options . setCacheEntry ,
47- options . getCacheEntry ,
48- authCacheTtl
49- )
50- ] : [ ] ) ,
51- ...( e . cors ? [ decorateAddCORSCallback ( ) ] : [ ] ) ,
52- executeLambdaCallback ( func ) ,
53- ]
54- )
54+ callbacks
55+ ) ;
5556 }
5657 }
5758 } ;
0 commit comments