-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (28 loc) · 923 Bytes
/
index.js
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
exports.handler = async (event) => {
const { body, httpMethod } = event;
let responseBody = 'ERROR';
let statusCode = '200';
const headers = { 'Content-Type': 'application/json' };
// Write anything you want here or write a case for another httpMethod that you need.
// It does not matter which file or how you handle this. Just call the thing you want to run in here.
try {
switch (httpMethod) {
case 'POST':
responseBody = 'SUCCEED';
break;
default:
throw new Error(`Unsupported method "${httpMethod}"`);
}
} catch (err) {
statusCode = '400';
responseBody = err.message;
} finally {
responseBody = JSON.stringify(responseBody);
}
console.log('Response Body ' + responseBody);
return {
statusCode,
body: responseBody,
headers,
};
};