Q:

Express routes and middleware

I'm using a role authorisation (connect-roles), and trying to add more than one role for each route. This is using express, and monogoose. Here is the code I currently have:
 router.get('/admin/:slug', function (req, res) {

   if (user.can('vip')) {

     adminController.showVipView // <-- this is what I need to work

   } else {

     // call a different view

   }

});

This is how it normally works without the if statement. This seems like super basic express, but I just cannot get it to work.
router.get('/admin/:slug', user.can('vip'), adminController.showVipView);

A:

Just pass request and response into it:
adminController.showVipView(req, res);

It might also requires the next callback, then you should pass that into it too...
By the way, your if statement wont work either as it returns a middleware. Might do this:
user.can('vip')(req, res, function(){
  adminController.showVipView(req, res);
});

