^
Error: Route.post() requires callback functions but got a [object Undefined]
at Route. (/home/azureuser/party/node_modules/express/lib/router/route.js:170:15)
at Array.forEach (native)
at Route.(anonymous function) [as post] (/home/azureuser/party/node_modules/express/lib/router/route.js:166:15)
at EventEmitter.app.(anonymous function) [as post] (/home/azureuser/party/node_modules/express/lib/application.js:429:19)
at module.exports (/home/azureuser/party/routes/index.js:8:5)
at Object. (/home/azureuser/party/app.js:33:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
//роутинг
var UserController = new require('../controllers/user')();
app.get('/users', UserController.findAll.bind(UserController));
//юзер
var mainController = require('./parent/index');
var UserController = function (){
UserController.super_.apply(this, 'User');
}
UserController.prototype = {
checkAuth : function(req, res, next){
if (req.session.user) {
res.json({"login": req.session.user});
}
else{
next();
}
},
login: function(req, res, next){
var mail = req.body.mail;
var password = req.body.password;
User.autorize(mail,password,function(err, result, user){
if (result.login == 'yes'){
req.session.user = user._id;
res.json(result);
}
else{
res.json({"login":"no"});
}
}
)
}
};
util.inherits(UserController, mainController);
module.exports = UserController;
//мэйн
function MainController() {
this.model = model;
}
MainController.prototype = {
findAll: function(req, res) {
model.find({}, function (err, res) {
if (err) res.json({"findAll":err});
res.json(res);
});
},
findById : function(req,res) {
var id = new ObjectID(req.params.id)
model.findById(id, function (err, res) {
if (err) res.json({"findById":err});
res.json(res);
})
},
create: function(req, res){
var saver = new model(req.body);
saver.save(function(err,res, affected){
if (err) throw err;
res.json({'create':'yes'});
});
},
update: function(req, res){
}
};
module.exports = MainController;