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

lambda-wrap

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-wrap

-----------------

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by10%
Maintainers
1
Weekly downloads
 
Created
Source

LambdaWrap


API

Classes

LambdaWrap

Functions

error(message, code)

Return new error object.

LambdaWrap

Kind: global class

  • LambdaWrap
    • new LambdaWrap([options])
    • ~wrap(fn)function

new LambdaWrap([options])

LambdaWrap constructor. You can pass options to override or assign new attributes to event object. For example add custom headers:


const headers = {
  'X-Auth-Token': 'my-token'
};

const wrap = new LambdaWrap({ headers });

It returns an instance of LambdaWrap - wrap object. This object can be used for specifying additional properties:


wrap.responseHandler = customResponseFunction;

Finally, wrap object can be used as a function to wrap any generator function and thus create lambda handler:


const handler = wrap(customGeneratorFunction);

Returns: Object - - New instance of LambdaWrap.

ParamTypeDefaultDescription
[options]Object{}Use to override or assign new attributes to event object. E.g. headers.

LambdaWrap~wrap(fn) ⇒ function

Kind: inner method of LambdaWrap Returns: function - - Lambda handler.

ParamTypeDescription
fnfunctionFunction to be wrapped and used as a lambda handler.

wrap.responseHandler

Override default response function

Kind: static property of wrap

wrap.errorResponseHandler

Override default error response function

Kind: static property of wrap

wrap.logger

Override default logger object - console. MUST implement log and error methods.

Kind: static property of wrap

wrap.before(fn)

Add new middleware.

Kind: static method of wrap

ParamTypeDescription
fnfunctionMiddleware function.

wrap.catch(fn)

Add new catch.

Kind: static method of wrap

ParamTypeDescription
fnfunctionCatch function.

error(message, code)

Return new error object.

Kind: global function

ParamTypeDescription
messagestringError message.
codeintegerError code.

FAQs

Package last updated on 24 Jan 2018

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