node.js - nodejs/express - cannot load routes using passport -


i trying use passport add user sessions on webapp. have configure main js file follow:

 /**  * module dependencies.  */ var express     = require('express'); var user        = require('./server/routes/user'); var routes      = require('./server/routes/index'); var http        = require('http'); var path        = require('path'); var app         = express(); var passport    = require('passport'); var flash       = require('connect-flash');  require('./server/config/passport')(passport); // pass passport configuration  // environments app.set('port', process.env.port || 3000); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.json()); app.use(express.urlencoded()); app.use(express.methodoverride()); app.use(app.router); app.use(require('stylus').middleware(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'public')));  app.configure(function(){     // required passport     app.use(express.session({ secret: 'ilovesefounders' })); // session secret     app.use(passport.initialize());     app.use(passport.session()); // persistent login sessions     app.use(flash()); // use connect-flash flash messages stored in session })   // routes ====================================================================== require('./server/routes/index')(app, passport); // load our routes , pass in our app , configured passport routes.mount(app); 

however when try launch following error:

require('./server/routes/index')(app, passport); // load our routes , pass                                 ^ typeerror: object not function     @ object.<anonymous> (/path/app.js:38:33)     @ module._compile (module.js:456:26)     @ object.module._extensions..js (module.js:474:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:312:12)     @ function.module.runmain (module.js:497:10)     @ startup (node.js:119:16)     @ node.js:902:3 

what's going wrong here?

i don't know how index.js looks did not export function module.

check if index.js looks this:

module.exports = function(app, passport) {     /* code */ }; 

and don't need require "./server/routes/index" again.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -