Skip to content

Instantly share code, notes, and snippets.

@allanchua101
Created August 22, 2020 14:00
Show Gist options
  • Save allanchua101/eaccfa4320be914f56355ecf33aacd2f to your computer and use it in GitHub Desktop.
Save allanchua101/eaccfa4320be914f56355ecf33aacd2f to your computer and use it in GitHub Desktop.
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