Skip to content

Instantly share code, notes, and snippets.

@dtolb
Last active January 26, 2016 19:55
Show Gist options
  • Save dtolb/cf5abc03730b832943e7 to your computer and use it in GitHub Desktop.
Save dtolb/cf5abc03730b832943e7 to your computer and use it in GitHub Desktop.
Callback Handler
module.exports.event = function (req, res, next) {
var hasBody = (typeof req.body !== 'undefined' && req.body !== null);
res.sendStatus(201); //Immediately respond to request
if (hasBody) {
var hasEvent = (typeof req.body.eventType !== 'undefined');
if (hasEvent) {
if (req.body.eventType === 'sms') {
logger.debug('Starting broadcast event');
bandcast.handleMessage({
fromNumber: req.body.from,
text: req.body.text
})
.catch(function (error) {
logger.error(error);
});
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment