Skip to content

Instantly share code, notes, and snippets.

@dashmug
Last active June 9, 2018 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dashmug/5cae542c111b2f9cd6d9c7ac3fff7b85 to your computer and use it in GitHub Desktop.
Save dashmug/5cae542c111b2f9cd6d9c7ac3fff7b85 to your computer and use it in GitHub Desktop.
// Main API Lambda
async function (event) {
let input
let context
let response
try {
// input is simply the relevant input (not the whole
// AWS Lambda event which contains lots of unnecessary data)
const input = getInputFromEvent(event)
// Context will contain some useful info like user, requestId, etc.
const context = getContextInfo(event)
response = await doSomething(input)
// Broadcast to an SNS Topic
// publishToSNS is a wrapper function that publishes to SNS
// the input, context, and response
await publishToSNS(input, context, response)
} catch (err) {
throw new Error(err)
}
return response
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment