lambda-wrapper
Advanced tools
Comparing version 0.1.2 to 0.2.0
29
index.js
@@ -65,2 +65,3 @@ 'use strict'; | ||
} catch (ex) { | ||
callback(ex); | ||
throw (ex); | ||
@@ -71,4 +72,11 @@ } | ||
run(event, callback) { | ||
return this.runHandler(event, {}, callback); | ||
run(event, context, callback) { | ||
let callbackFunction = callback; | ||
let contextObject = context; | ||
if (typeof context === 'function') { | ||
// backwards compability | ||
callbackFunction = context; | ||
contextObject = {}; | ||
} | ||
return this.runHandler(event, contextObject, callbackFunction); | ||
} | ||
@@ -96,11 +104,18 @@ } | ||
}, | ||
run: (event, callback) => new Promise((resolve, reject) => { | ||
run: (event, context, callback) => new Promise((resolve, reject) => { | ||
let callbackFunction = callback; | ||
let contextObject = context; | ||
if (typeof context === 'function') { | ||
// backwards compability | ||
callbackFunction = context; | ||
contextObject = {}; | ||
} | ||
if (typeof latest === typeof undefined) { | ||
const error = 'Module not initialized'; | ||
reject(error); | ||
return callback(error, null); | ||
return callbackFunction(error, null); | ||
} | ||
return latest.run(event, (err, data) => { | ||
if (callback) { | ||
return callback(err, data); | ||
return latest.run(event, contextObject, (err, data) => { | ||
if (callbackFunction) { | ||
return callbackFunction(err, data); | ||
} | ||
@@ -107,0 +122,0 @@ if (err) { |
{ | ||
"name": "lambda-wrapper", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Wrapper for running Amazon Lambda modules locally", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "RUN_LIVE=true npm run unit-tests", | ||
"unit-tests": "./node_modules/.bin/mocha" | ||
}, | ||
@@ -33,4 +34,3 @@ "repository": { | ||
}, | ||
"dependencies": { | ||
} | ||
"dependencies": {} | ||
} |
# lambda-wrapper | ||
[![Build Status](https://travis-ci.org/SC5/lambda-wrapper.svg?branch=master)](https://travis-ci.org/SC5/lambda-wrapper) | ||
Wrapper for running lambda modules locally or from AWS during development | ||
@@ -34,2 +37,4 @@ | ||
Documentation for valid propreties in the Lambda context object are documented here http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html | ||
Exceptions from within the module will be returned as errors via the callback / promise. | ||
@@ -47,2 +52,4 @@ ## Development | ||
* 2017/07/09 - v0.2.0 - Return exceptions as errors via callback | ||
* 2017/06/16 - v0.1.3 - Allow context object in run | ||
* 2016/10/21 - v0.1.2 - Support for using promises | ||
@@ -58,6 +65,3 @@ * 2016/07/26 - v0.1.1 - Support for alternative handler. runHandler method for passing custom context. | ||
Copyright (c) 2015 [SC5](http://sc5.io/), licensed for users and contributors under MIT license. | ||
https://github.com/SC5/aws-document-cache/blob/master/LICENSE | ||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/SC5/lambda-local/trend.png)](https://bitdeli.com/free "Bitdeli Badge") | ||
Copyright (c) 2016 [SC5](http://sc5.io/), licensed for users and contributors under MIT license. | ||
https://github.com/SC5/lambda-wrapper/blob/master/LICENSE |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
10
65
0
8621
111