in code/index.js [147:182]
function responseToApiGw(statusCode, detail) {
if (!statusCode) {
throw new TypeError('responseToApiGw() expects at least argument statusCode');
}
if (statusCode !== '200' && !detail) {
throw new TypeError('responseToApiGw() expects at least arguments statusCode and detail');
}
let body = {};
if (statusCode === '200' && detail) {
body = {
statusCode: statusCode,
message: detail
};
} else if (statusCode === '200' && !detail) {
body = {
statusCode: statusCode
};
} else {
body = {
statusCode: statusCode,
fault: detail
};
}
let response = {
statusCode: statusCode,
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET',
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept'
}
};
return response;
}