Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Cosmic Messenger Twiliio Notifications middleware
var twilioClient = require('./twilioClient');
const admins = require('./config').adminNumbers;
function formatMessage(user, messageText) {
return `Message from ${user}: ${messageText}`;
exports.notifyOnMessage = function (req, res, next) {
if (req.session) {
const { title, content } = req.body;
admins.forEach(function (admin) {
var messageToSend = formatMessage(title, content);
twilioClient.sendSms(admin.phoneNumber, messageToSend);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.