1.1.2 • Published 7 years ago

apigateway-http-request v1.1.2

Weekly downloads
3
License
MIT
Repository
-
Last release
7 years ago

apigateway-http-request Build Status

For use with AWS Lambda. Parses an incoming API Gateway event into a more familiar structure similar to an express req.

Getting started

Here's an example AWS Lambda function that echos back incoming request body.

import { fromIncomingEvent, ApigatewayHttpSuccessResponse } from 'apigateway-http-request'

export default { 
  handler(event, context, callback) {
    let req = fromIncomingEvent(event); // returns an ApigatewayHttpRequest
    console.log(req);
    // optionally use included response
    let body        = { timestamp: Date.now(), echo: req.body };
    let statusCode  = 200;
    let headers     = { 'Some-Header': 'hi' };
    // if no requestId is supplied one will be generated
    // let requestId   = 'generated request id or one supplied by aws';
    let res = new ApigatewayHttpSuccessResponse(body, statusCode, headers, requestId);
    callback(null, res.format());
  }
};
1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago