1.1.0 • Published 9 years ago

lambda-router-adapter v1.1.0

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
9 years ago

lambda-router-adapter

Adapts Lambda Router Requests and Responses to NodeJS HTTP Request and Responses. This is a utility library for implementing AWS Lambda functions that receive events from the github.com/jamiemccrindle/lambda-router project.

Usage

Express 4.x

lambda-router-adapter has built in support for express 4.x. Use the newExpressHandler method to convert an express app into a lambda handler.

var express = require('express');
var adapter =require('lambda-router-adapter');
var app = express();

app.get('/', function(req, res) {
    res.send('Hello World');
});

module.exports.handler = adapter.newExpressHandler(app);

Generic

convertRequest

Convert a lambda event into a LambdaHttpRequest, which has the same interface as a NodeJS http request.

The lambda event must have the following fields:

  • url
  • method

The lambda event could have the following fields:

  • body
  • headers

newResponse

Create a new LambdaHttpResponse which has the same interface as a NodeJS http response.

convertResponse

Serialise the LambdaHttpResponse into an object that can be sent as a lambda response.

The response will have the following fields:

  • statusCode
  • statusMessage
  • headers
  • body or bodyBase64
1.1.0

9 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago