-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.mjs
23 lines (22 loc) · 862 Bytes
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
export const handler = async (event) => {
const promise = new Promise((resolve, reject) => {
// randomly return success or failure with the appropriate status code
let success = Math.floor(Math.random() * 2) == 1;
let statusCode = (success ? 200 : 500)
let returnObject = {
"success": success,
"notice": `Please note that status code and "success" value are randomly determined`,
"querystring": event.queryStringParameters
};
resolve({
"isBase64Encoded": false,
"statusCode": statusCode,
"headers": {
'Access-Control-Allow-Origin': process.env.CORS_ORIGIN,
'Access-Control-Allow-Credentials': true,
},
"body": JSON.stringify(returnObject)
});
});
return promise;
}