lambda-wrapper
Advanced tools
Comparing version 0.0.4 to 0.0.5
42
index.js
@@ -1,9 +0,10 @@ | ||
// Pseudowrapper for AWS Lambda | ||
var lambdaModule; | ||
var _runner = function(event, callback) { | ||
if (!lambdaModule) { | ||
return callback('Module not initialized', null); | ||
} | ||
// Wrapper class for AWS Lambda | ||
function Wrapped(mod) { | ||
this.lambdaModule = mod; | ||
} | ||
Wrapped.prototype.run = function(event, callback) { | ||
var lambdacontext = { | ||
@@ -22,3 +23,3 @@ succeed: function(success) { | ||
try { | ||
lambdaModule.handler(event, lambdacontext); | ||
this.lambdaModule.handler(event, lambdacontext); | ||
} catch (ex) { | ||
@@ -29,8 +30,31 @@ throw(ex); | ||
// Wrapper factory | ||
function wrap(mod) { | ||
var wrapped = new Wrapped(mod); | ||
return wrapped; | ||
} | ||
// Static variables (for backwards compatibility) | ||
var latest; | ||
// Public interface for the module | ||
module.exports = exports = { | ||
// reusable wrap method | ||
wrap: wrap, | ||
// static init/run interface for backwards compatibility | ||
init: function(mod) { | ||
lambdaModule = mod; | ||
latest = wrap(mod); | ||
}, | ||
run: _runner | ||
run: function(event, callback) { | ||
if (typeof latest === typeof undefined) { | ||
return callback('Module not initialized', null); | ||
} else { | ||
latest.run(event, callback); | ||
} | ||
} | ||
}; |
{ | ||
"name": "lambda-wrapper", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Wrapper for running Amazon Lambda modules locally", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/SC5/lambda-local.git" | ||
"url": "https://github.com/SC5/lambda-wrapper.git" | ||
}, | ||
@@ -20,7 +20,14 @@ "keywords": [ | ||
"author": "Mikael Puittinen (mikael.puittinen@sc5.io)", | ||
"contributors": [ | ||
"Toni Ruottu (https://sc5.io)" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/SC5/lambda-local/issues" | ||
"url": "https://github.com/SC5/lambda-wrapper/issues" | ||
}, | ||
"homepage": "https://github.com/SC5/lambda-local" | ||
"homepage": "https://github.com/SC5/lambda-wrapper", | ||
"devDependencies": { | ||
"chai": "3.5.0", | ||
"mocha": "2.4.5" | ||
} | ||
} |
@@ -10,3 +10,3 @@ # lambda-wrapper | ||
var lambdaFunc = require('myModule/mymod.js'); | ||
var lambda = require('lambda-wrapper').init(lambdaFunc); | ||
var lambda = require('lambda-wrapper').wrap(lambdaFunc); | ||
@@ -25,4 +25,4 @@ ### Running the function in the Lambda module | ||
* 2015/09/01 - v0.0.2 - Pass module object rather than path to init(). | ||
Removed automatic loading of module. | ||
* 2015/09/01 - v0.0.2 - Pass module object rather than path to init(). | ||
Removed automatic loading of module. | ||
* 2015/07/23 - v0.0.1 - Initial version of module | ||
@@ -36,2 +36,2 @@ | ||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/SC5/lambda-local/trend.png)](https://bitdeli.com/free "Bitdeli Badge") | ||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/SC5/lambda-local/trend.png)](https://bitdeli.com/free "Bitdeli Badge") |
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
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
6839
8
92
35
2