Created
August 22, 2020 14:00
-
-
Save allanchua101/eaccfa4320be914f56355ecf33aacd2f to your computer and use it in GitHub Desktop.
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
const { getWeapons } = require("./modules/weapons-query"); | |
const { buildResponse } = require(process.env.AWS | |
? "/opt/nodejs/response-builder" | |
: "../base-layer/nodejs/response-builder"); | |
const { sendAlert } = require(process.env.AWS | |
? "/opt/nodejs/slack-alarm" | |
: "../base-layer/nodejs/slack-alarm"); | |
module.exports = { | |
async execute(event, context) { | |
if (event.httpMethod && event.httpMethod.toLowerCase() === "options") { | |
return buildResponse(200, {}); | |
} | |
try { | |
let items = await getWeapons(); | |
return buildResponse(200, { items }); | |
} catch (err) { | |
await sendAlert(err); | |
return buildResponse(500, { issue: "Internal server error" }); | |
} | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment