Skip to content

Instantly share code, notes, and snippets.

@NizarOukhchi
Last active February 26, 2016 12:07
Show Gist options
  • Save NizarOukhchi/364f70055f224b646173 to your computer and use it in GitHub Desktop.
Save NizarOukhchi/364f70055f224b646173 to your computer and use it in GitHub Desktop.
Create model and broadcast it (after)
/* app/server/api/model/model.controller.js */
var Model = require('./model');
var ioEmitter = require('../../config/sockets');
exports.create = function (req, res) {
Model.create(req.body, function (err, model) {
if (err) {
return res.status(500).send(err);
}
ioEmitter.emit('Model:new', model);
return res.status(201).json(model);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment