Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lambda-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-wrapper - npm Package Compare versions

Comparing version 0.0.6 to 0.1.0

lambdaWrapper-test.js

28

index.js

@@ -8,4 +8,4 @@

}
Wrapped.prototype.run = function(event, callback) {
var lambdacontext = {

@@ -24,3 +24,26 @@ succeed: function(success) {

try {
this.lambdaModule.handler(event, lambdacontext, callback);
if (this.lambdaModule.handler) {
this.lambdaModule.handler(event, lambdacontext, callback);
} else {
var AWS = require('aws-sdk');
if (this.lambdaModule.region) {
AWS.config.update({
region: this.lambdaModule.region
});
}
var lambda = new AWS.Lambda();
var params = {
FunctionName: this.lambdaModule.lambdaFunction,
InvocationType: 'RequestResponse',
LogType: 'None',
Payload: JSON.stringify(event),
};
lambda.invoke(params, function(err, data) {
if (err) {
return callback(err);
}
callback(null, JSON.parse(data.Payload));
});
}
} catch (ex) {

@@ -35,2 +58,3 @@ throw(ex);

var wrapped = new Wrapped(mod);
return wrapped;

@@ -37,0 +61,0 @@ }

3

package.json
{
"name": "lambda-wrapper",
"version": "0.0.6",
"version": "0.1.0",
"description": "Wrapper for running Amazon Lambda modules locally",

@@ -28,2 +28,3 @@ "main": "index.js",

"devDependencies": {
"aws-sdk": "^2.4.0",
"chai": "3.5.0",

@@ -30,0 +31,0 @@ "mocha": "2.4.5"

# lambda-wrapper
Wrapper for running lambda modules locally during development
Wrapper for running lambda modules locally or from AWS during development

@@ -12,6 +12,13 @@ ## Use

### Initializing a lambda in AWS
var lambda = require('lambda-wrapper').wrap({
region: 'eu-west-1',
lambdaFunction: 'myFunctionName'
});
### Running the function in the Lambda module
var event = { key1: 'val1', key2: val2 };
lambda.run({Payload: event}, function(err, data) {
lambda.run(event, function(err, data) {
if (err) {

@@ -23,4 +30,15 @@ ... handle error

## Development
Run module tests using
npm run test
Live lambda run test requires that the function in lambdaWrapper-test.js is deployed
to your AWS account as 'lambdaWrapper-test'.
## Release History
* 2016/04/26 - v0.1.0 - Support for running lambda functions also from AWS
* 2016/04/26 - v0.0.6 - Support for NodeJS 4.3 runtime (and callback notation)
* 2015/09/01 - v0.0.2 - Pass module object rather than path to init().

@@ -27,0 +45,0 @@ Removed automatic loading of module.

@@ -66,2 +66,18 @@ var testMod1 = {

});
it('can call lambda functions deployed in AWS', function(done) {
var wLive = wrapper.wrap({
lambdaFunction: 'lambdaWrapper-test',
region: process.env.AWS_DEFAULT_REGION || 'eu-central-1'
});
wLive.run({test: 'livesuccess'}, function(err, response) {
if (err) {
return done(err);
}
expect(response.src).to.be.equal('lambda');
expect(response.event.test).to.be.equal('livesuccess');
done();
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc