Skip to content

Instantly share code, notes, and snippets.

@gocreating
Created July 28, 2014 18:06
Show Gist options
  • Save gocreating/a089760c135ab9c20182 to your computer and use it in GitHub Desktop.
Save gocreating/a089760c135ab9c20182 to your computer and use it in GitHub Desktop.
var User = require('../../models/user');
module.exports = function (router) {
router.route('/api/user')
.get(function (req, res) {
console.log('get');
User.readAll(function (err, readUsers) {
// reply is a custom function added by my middleware
res.reply(readUsers, err, 'cannot read users');
});
})
.post(function (req, res) {
console.log('post');
User.checkExist(req.body.email, function (err, isExist) {
User.create(function (err, readUserId) {
// reply is a custom function added by my middleware
res.reply(readUserId, err, 'cannot create the new user');
});
});
})
.put(function (req, res) {
})
.delete(function (req, res) {
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment