Last active
February 26, 2016 12:07
-
-
Save NizarOukhchi/364f70055f224b646173 to your computer and use it in GitHub Desktop.
Create model and broadcast it (after)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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