So, I just started with expressjs 4.0.0
and came across the express.Router()
object, which is really nice.
Problem is, now that all my routes are in another file, how do I expose an object to the routes file ?
serverjs file:
...
var passport = require('passport');
var router = require('./app/routes.js')(passport); //WILL NOT WORK
app.use('/', router);
app.listen(8080);
routes.js file:
...
var express = require('express');
var router = express.Router(); //new feature in expressjs 4.0
//routes go here
module.export = router;
So, how should I access passport object in router file ? Should I create a new object or is there a way to pass the server.js object to router.js file ?