Socket
Socket
Sign inDemoInstall

lambda-api-gateway-response

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lambda-api-gateway-response

API Gateway Response builder for AWS Lambda


Version published
Maintainers
1
Created

Readme

Source

API Gateway Response builder for AWS Lambda

Build Status codecov Codacy Badge Maintainability

Install

NPM

npm i lambda-api-gateway-response

Usage

Chainable methods

Method      DescriptionDefault value
statusSet HTTP status code200
headersSet response headers-
bodySet response bodynull
send        Invoke callback              -      

This

new ApiGatewayResponse(callback)
    .status(200)
    .headers({
        'access-control-allow-origin': '*'
    })
    .body({
        "foo": "bar"
    })
    .send();

will be send as:

{
    statusCode: 200,
    headers: {
        "access-control-allow-origin": "*"
    },
    body: {
        "foo": "bar"
    }
}

Example

var ApiGatewayResponse = require('lambda-api-gateway-response');

exports.myHandler = function(event, context, callback) {
 return new ApiGatewayResponse(callback)
    .status(200)
    .headers({
        'access-control-allow-origin': '*'
    })
    .body({
        "foo": "bar"
    })
    .send();
}

Contribute

If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.

Keywords

FAQs

Last updated on 15 Jul 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc