Created
July 28, 2014 18:06
-
-
Save gocreating/a089760c135ab9c20182 to your computer and use it in GitHub Desktop.
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
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