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

lambda-executor

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-executor

A library to easily execute lambda functions

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Lambda Executor

Travis npm

A library to easily execute AWS lambda functions from JavaScript code.

How it works

Pass the lambda function file name and event object to this tester. The lambda function will be executed either

  • in a separate process with limited time and memory, the same way it is executed in the lambda environment
  • in the same process just limited by time

Install

npm install lambda-executor --save-dev

Usage

API

lambdaTester(fileName, handlerName, event, timeout, memory, callback, sameProcess, babel)

  • fileName : absolute filename of lambda function
  • handlerName : name of exported handler function (default: handler)
  • event : JSON event object
  • timeout : timeout in milliseconds
  • memory : maximum available memory in MB
  • callback(err, result) : callback function which is executed after execution completed
  • sameProcess (optional) : boolean if executor should not create a separate child process to execute the function (default: false)
  • babel (optional) : boolean if babel should be registered to execute es2015 code (default: false)

Example

var lambdaExecutor = require('lambda-executor');
var path = require('path');

describe('My Tests', function() {
  it('should succeed', function(done) {
    lambdaExecutor(path.join(__dirname, 'function.js'), 'handler', {}, 10, 128, function(err, result) {
      //insert assertions here
      done();
    });
  });
});

Modes

Different process (default)

By default functions are executed in a different process. This makes the execution very similar to how it is executed on AWS. However, in this mode you can only return plain objects (without any functions) from the function. The executer uses communication via process messages which can only plain objects (https://nodejs.org/api/child_process.html#child_process_event_message). Also it is not possible to record code coverage if the function is executed in a separate process.

Same process

If you use the local mode you can return anything from the lambda function (including Error objects). Also code coverage can be recorded. However, the execution won't stop if the function consumes more memory then specified.

License

MIT

Keywords

FAQs

Package last updated on 02 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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