New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lambda-server

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-server

Module for generic initalization of lambda processes and requests

  • 0.9.2
  • latest
  • Source
  • npm
  • Socket score

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

lambda-server NPM module

A module for providing some basic services to serverles services implemented by AWS Lambda. For the time being, the server only intitializes a the STACK_NAME environment variable to contain the Cloudformation stack name (based on the function name, e.g. ABC-functionName-123456 => STACK_NAME=ABC). More logic can and will be added later.

Usage

Package your lambda function into a module lambdaFunction.js with syntax

  var lambdaServer;

  function init(server) {
      lambdaServer = server;
  }

  function handleRequest(event, cb) {
      if (ERROR) {
          cb(ERROR MESSAGE HERE)
      } 
      console.log('I am in CloudFormation stack ' + process.env.STACK_NAME);

      cb(null, {
          ... YOUR RESPONSE OBJECT HERE
      });
  }

  module.exports = exports = {
      init: init,
      handleRequest: handleRequest
  };

The index.js for your lambda-server based service would be e.g.

  var server = require('lambda-server');
  var lambdaFunction = require('./lambdaFunction.js');

  server.init({
      lambdaFunction: lambdaFunction 
  });

  module.exports = exports = {
      handler : server.handler
  };

An alternative error handler can be registered (e.g. for logging / notifications) by passing the error handler function in 'errorHandler' during lambda-server-init. e.g.

  var server = require('lambda-server');
  var lambdaFunction = require('./lambdaFunction.js');
  var myErrorHandler = function(error, callback) {
    call_your_logging_function_here(error, callback);
  }

  server.init({
      lambdaFunction: lambdaFunction,
      errorHandler: myErrorHandler
  });

  module.exports = exports = {
      handler : server.handler
  };

TODO

Ideas for future versions:

  1. hook for keeping the function awake triggered via scheduled event
  2. generic method to manage configuration data for Lambda-based services
  3. functions to ease deployment to Lambda

Release History

  • 2016/01/12 - v0.9.2 - Invoke errorHandler also on Exceptions
  • 2015/11/30 - v0.9.1 - Added capability to register alternative error Handler
  • 2015/10/23 - v0.9.0 - Initial version of module

License

Copyright (c) 2015 SC5, licensed for users and contributors under MIT license. https://github.com/SC5/lambda-server/blob/master/LICENSE

Bitdeli Badge

Keywords

FAQs

Package last updated on 12 Jan 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