forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.ts
28 lines (23 loc) · 788 Bytes
/
handler.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
import * as aws from "@pulumi/aws";
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
/**
* A simple function that returns the request.
*
* @param {APIGatewayProxyEvent} event -
* @returns returns a confirmation to the message to the
*/
export const handler: aws.lambda.EventHandler<APIGatewayProxyEvent, APIGatewayProxyResult> = async (event) => {
const route = event.pathParameters!["route"];
const body = event.body ? JSON.parse(event.body) : null;
console.log("Received body: ", body);
return {
statusCode: 200,
body: JSON.stringify({
route,
affirmation: "Nice job, you've done it! :D",
requestBodyEcho: body,
}),
};
};
export default handler;