-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.ts
More file actions
33 lines (31 loc) · 802 Bytes
/
hello.ts
File metadata and controls
33 lines (31 loc) · 802 Bytes
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
29
30
31
32
33
import { promisify } from "util";
const timeout = promisify(setTimeout);
const log = (message: string) =>
console.log(`${new Date().toISOString()}: ${message}`);
if (process.env.IS_OFFLINE === "true") {
console.debug("This is running offline");
}
export async function handler(
event: AWSLambda.APIGatewayEvent,
context: AWSLambda.Context
): Promise<AWSLambda.APIGatewayProxyResult> {
try {
log(`function hello invoked!`);
const env_var_inside_lambda = process.env.ENV_VAR_INSIDE_LAMBDA;
await timeout(1000);
return {
statusCode: 200,
body: JSON.stringify({
hello: "World!",
event,
context,
env_var_inside_lambda
})
};
} catch (e) {
return {
statusCode: 500,
body: "Something went wrong!"
};
}
}