Skip to content

Commit

Permalink
Linting aws-ts-apigateway-lambda-serverless
Browse files Browse the repository at this point in the history
  • Loading branch information
stack72 committed May 10, 2021
1 parent 0ef3bfc commit 3c61f1c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
24 changes: 12 additions & 12 deletions aws-ts-apigateway-lambda-serverless/handler.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
'use strict'
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
import * as aws from '@pulumi/aws';
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
*
* @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);
console.log("Received body: ", body);

return {
statusCode: 200,
body: JSON.stringify({
route,
affirmation: "Nice job, you've done it! :D",
requestBodyEcho: body
})
}
}
requestBodyEcho: body,
}),
};
};

export default handler;
export default handler;
20 changes: 11 additions & 9 deletions aws-ts-apigateway-lambda-serverless/index.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.

import * as awsx from "@pulumi/awsx";
import handler from './handler';
import handler from "./handler";

/**
* api-gatewayx https://www.pulumi.com/docs/guides/crosswalk/aws/api-gateway/
*/

// Create an API endpoint.
let endpoint = new awsx.apigateway.API("hello-world", {
const endpoint = new awsx.apigateway.API("hello-world", {
routes: [
{
path: "/{route+}",
method: "GET",
// Functions can be imported from other modules
eventHandler: handler
eventHandler: handler,
},
{
path: "/{route+}",
method: "POST",
// Functions can be created inline
eventHandler: (event) => {
console.log('Inline event handler');
console.log("Inline event handler");
console.log(event);
}
},
},
{
path: "/{route+}",
method: "DELETE",
// Functions can be created inline
eventHandler: (event) => {
console.log('Inline delete event handler');
console.log("Inline delete event handler");
console.log(event);
}
},
},
],
});

// Pulumi exports values
// Pulumi exports values
// See these outputs using: pulumi stack output endpointUrl
export const endpointUrl = endpoint.url;
export const endpointUrl = endpoint.url;

0 comments on commit 3c61f1c

Please sign in to comment.