Simple handling of requests and responses within AWS API Gateway Lambda Proxy integrations running NodeJS 8.10.
npm install aws-apigateway-controllerSimple handling of requests and responses within AWS API Gateway Lambda Proxy integrations running NodeJS 8.10.
npm install --save aws-apigateway-controller
const { Controller, Request, Response } = require('aws-apigateway-controller');
module.exports.handler = (event, context) => {
return Controller.handle(event, context, (request) => {
return new Response(200, Executed handler for ${request.method} ${request.path} successfully.);
});
};
Be sure to have run npm install --save-dev @types/aws-lambda @types/node to have the required types available.
import { APIGatewayProxyEvent, APIGatewayEventRequestContext } from 'aws-lambda'
import { Controller, Request, Response } from 'aws-apigateway-controller';
export async function handler(event: APIGatewayProxyEvent, context: APIGatewayEventRequestContext) {
return Controller.handle(event, context, (request: Request) => {
return new Response(200, Executed handler for ${request.method} ${request.path} successfully.);
});
}