forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linting aws-ts-apigateway-lambda-serverless
- Loading branch information
Showing
2 changed files
with
23 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |