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

express-gateway-plugin-lambda

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-gateway-plugin-lambda

Proxy to AWS Lambda functions with Express Gateway.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
58
increased by163.64%
Maintainers
1
Weekly downloads
 
Created
Source

npm CircleCI Gitter

Express Gateway AWS Lambda Plugin

  • Proxy to AWS Lambda functions with Express Gateway

Plugin Settings

  • invocationType - [RequestResponse (default) | Event | DryRun] - AWS Lambda invocation type.
  • logType - [None (default) | Tail] - AWS Lambda log type.
  • unhandledStatus - [default: 500] - When the Lambda function returns with an unhandled error, usually due to an absence of available resources, this status code will be returned to the client.
  • useCustomIntegration - [true | false (default)] - Use a custom integration as specified by the req.egContext.lambda object.
  • maxJSONParseLength - [(default: 5 * 1.049e+6, 5MiB)] - Maximum number of bytes to allow for parsing responses as JSON in an attempt to guess the MIME type.

lambda-proxy Policy

Policy Settings

All plugin settings can be overridden on a per-policy basis. In addition, here are some policy-specific settings:

  • functionName - [(required)] - Specify the Lambda function name.
  • qualifier - [(optional)] - Specify a Lambda function version or alias name.
  • ignorePath- [true | false (default), (optional, only valid when using Proxy Integration)] - Don't proxy to the incoming request's URL path.
  • stripPath - [true | false (default), (optional, only valid when using Proxy Integration)] - Strip the API Endpoint path prefix from the forwarded URL path.

Integration Modes

Proxy Integration

Proxy Integration mode sends the Lambda function an event that looks similar to an AWS API Gateway event. The response is expected to be in the same format as the AWS API Gateway Lambda response.

Proxy Integration Lambda Event

With Proxy Integration mode, the HTTP request gets turned into a JSON object that gets invoked with the Lambda function.

Here's an example:

{
  "httpMethod": "POST",
  "path": "/California?name=Kevin",
  "resource": "/:proxy",
  "queryStringParameters": {
    "name": "Kevin"
  },
  "pathParameters": {
    "proxy": "California"
  },
  "headers": {
    "host": "localhost:60852",
    "user-agent": "curl/7.51.0",
    "accept": "*/*",
    "content-type": "application/json",
    "day": "Thursday",
    "content-length": "18"
  },
  "requestContext": {
    "apiEndpoint": {
      "apiEndpointName": "default",
      "host": "*",
      "path": "/:proxy",
      "paths": "/:proxy",
      "scopes": []
    },
    "resourcePath": "/:proxy",
    "httpMethod": "POST",
    "requestId": "3SpeBYb8SK6CvH7Ipx56pK"
  },
  "isBase64Encoded": false,
  "body": "{\"time\":\"morning\"}"
}
Proxy Integration Lambda Response

The Lambda response must use the following JSON structure:

{
    "isBase64Encoded": true|false,
    "statusCode": httpStatusCode,
    "headers": { "headerName": "headerValue", ... },
    "body": "..."
}

If no Content-Type header is provided, this plugin will take a buest guess at the MIME type before sending the response to the client. It is recommended to always include a Content-Type header.

Custom Integration

Requires the setting useCustomIntegration to equal true.

Custom Integration Mode takes a look at the req.egContext.lambda object and forwards that as the incoming event to the AWS Lambda function. The response is taken, the content type is guessed, and it finally returns to the client.

If the req.egContext.lambda object is not populated, a default event structure will be sent to the AWS Lambda function. Example:

{
  "method": "POST",
  "path": "/California?name=Kevin",
  "headers": {
    "host": "localhost:61636",
    "user-agent": "curl/7.51.0",
    "accept": "*/*",
    "content-type": "application/json",
    "day": "Thursday",
    "content-length": "18"
  },
  "body": "{\"time\":\"morning\"}"
}

This plugin will attempt a best guess at the Content-Type of the response. It is recommended to use Proxy Integration whenever possible.

License

Apache-2.0 License

Copyright © LunchBadger, Inc. and Contributors

Keywords

FAQs

Package last updated on 17 Oct 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