lambda-wrapper
Advanced tools
Comparing version 0.2.2 to 0.3.0
23
index.js
@@ -15,2 +15,7 @@ 'use strict'; | ||
this.handler = mod[handler]; | ||
} else { | ||
if (!this.lambdaModule.lambdaFunction) { | ||
throw new Error("Invalid input. Expected either lambda module (with exposed handler) " + | ||
"or AWS Lambda configuration (with provided 'lambdaFunction' name)"); | ||
} | ||
} | ||
@@ -40,4 +45,18 @@ } | ||
try { | ||
if (this.handler) { | ||
this.handler(event, lambdaContext, callback); | ||
if (this.handler) { | ||
const handlerResult = this.handler(event, lambdaContext, callback); | ||
// Check if the result itself is a promise | ||
if (handlerResult && handlerResult.then) { | ||
handlerResult.then(function(data) { | ||
// Avoid Maximum call stack size exceeded exceptions | ||
return setImmediate(function() { | ||
callback(null, data); | ||
}); | ||
}).catch(function(err) { | ||
// Avoid Maximum call stack size exceeded exceptions | ||
return setImmediate(function() { | ||
callback(err); | ||
}); | ||
}); | ||
} | ||
} else { | ||
@@ -44,0 +63,0 @@ if (this.lambdaModule.region) { |
{ | ||
"name": "lambda-wrapper", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "Wrapper for running Amazon Lambda modules locally", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/SC5/lambda-wrapper.git" | ||
"url": "https://github.com/nordcloud/lambda-wrapper.git" | ||
}, | ||
@@ -20,12 +20,12 @@ "keywords": [ | ||
], | ||
"author": "Mikael Puittinen (mikael.puittinen@sc5.io)", | ||
"author": "Mikael Puittinen (https://nordcloud.com)", | ||
"contributors": [ | ||
"Toni Ruottu (https://sc5.io)", | ||
"Eetu Tuomala (https://sc5.io)" | ||
"Toni Ruottu", | ||
"Eetu Tuomala" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/SC5/lambda-wrapper/issues" | ||
"url": "https://github.com/nordcloud/lambda-wrapper/issues" | ||
}, | ||
"homepage": "https://github.com/SC5/lambda-wrapper", | ||
"homepage": "https://github.com/nordcloud/lambda-wrapper", | ||
"devDependencies": { | ||
@@ -32,0 +32,0 @@ "chai": "3.5.0", |
# lambda-wrapper | ||
[![Build Status](https://travis-ci.org/SC5/lambda-wrapper.svg?branch=master)](https://travis-ci.org/SC5/lambda-wrapper) | ||
[![Build Status](https://travis-ci.org/nordcloud/lambda-wrapper.svg?branch=master)](https://travis-ci.org/nordcloud/lambda-wrapper) | ||
@@ -51,2 +51,3 @@ Wrapper for running lambda modules locally or from AWS during development | ||
* 2018/05/07 - v0.3.0 - Support for async calls, improved input validation | ||
* 2017/07/09 - v0.2.0 - Return exceptions as errors via callback | ||
@@ -64,3 +65,3 @@ * 2017/06/16 - v0.1.3 - Allow context object in run | ||
Copyright (c) 2016 [SC5](http://sc5.io/), licensed for users and contributors under MIT license. | ||
https://github.com/SC5/lambda-wrapper/blob/master/LICENSE | ||
Copyright (c) 2016 [Nordcloud](https://nordcloud.com/), licensed for users and contributors under MIT license. | ||
https://github.com/nordcloud/lambda-wrapper/blob/master/LICENSE |
Sorry, the diff of this file is not supported yet
9672
132
66
9