Skip to content

Instantly share code, notes, and snippets.

@rts-rob
Last active September 12, 2017 07:34
Show Gist options
  • Save rts-rob/da4b878cc7bf8c21e7c16cb4e64e939b to your computer and use it in GitHub Desktop.
Save rts-rob/da4b878cc7bf8c21e7c16cb4e64e939b to your computer and use it in GitHub Desktop.
Main function of Promise-based refactor of our self-service database reset function via slack
module.exports.reset = (event, context, callback) => {
const targetUserAgent = 'slackbot';
const targetSlackTeam = 'SomeSlackTeam';
validateUserAgent(event, targetUserAgent)
.then(requestBody => validateSlackTeam(requestBody, targetSlackTeam))
.then(validatedRequestBody => extractUser(validatedRequestBody))
.then(extractedUser => resetDB(extractedUser))
.then(response => callback(null, response))
.catch(error => callback(error));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment