Skip to content

Commit 0965e60

Browse files
committed
Node 4.3 compatibility
1 parent c1ed8de commit 0965e60

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

index.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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
};

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"name": "serverlessify",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Utility to simulate AWS Lambda event sources and write a server for Serverless functions",
55
"main": "index.js",
6+
"engines": {
7+
"node": ">=4.3"
8+
},
69
"scripts": {
710
"test": "istanbul cover _mocha tests/all.test.js -- -R spec --recursive"
811
},

0 commit comments

Comments
 (0)