title: Passport authentication error
body: <p>When I executed the main app along with passport-facebook module I get the following error. I tried <code>npm install passport-facebook</code> again but there was no change. I need help to solve this issue. Is <code>authenticate()</code> a pre-defined method of passport module?</p>
  
  <pre><code>C:\codebag\app\routes.js:53
  app.get('/api/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));
                                         ^
  
  TypeError: Cannot read property 'authenticate' of undefined
      at module.exports (C:\codebag\app\routes.js:53:43)
      at Object.&lt;anonymous&gt; (C:\codebag\server.js:49:24)
      at Module._compile (module.js:413:34)
      at Object.Module._extensions..js (module.js:422:10)
      at Module.load (module.js:357:32)
      at Function.Module._load (module.js:314:12)
      at Function.Module.runMain (module.js:447:10)
      at startup (node.js:139:18)
      at node.js:999:3
  </code></pre>
  
  <p>routes.js</p>
  
  <pre><code>var express = require('express')
  //var router = express.Router();
  module.exports = function(app,passport) {
      app.get('*', function(req, res) {
          res.sendfile('./public/index.html');
      });
  
      // route for facebook authentication and login
      app.get('/api/auth/facebook', passport.authenticate('facebook', { scope : 'email' }));
  
      // handle the callback after facebook has authenticated the user
      app.get('/api/auth/facebook/callback', passport.authenticate('facebook', {
          successRedirect : '/profile',
          failureRedirect : '/'
      }));
  
      // route for logging out
      app.get('/api/logout', function(req, res) {
          req.logout();
          res.redirect('/');
      });
  };
  
  // route middleware to make sure a user is logged in
  function isLoggedIn(req, res, next) {
      // if user is authenticated in the session, carry on
      if (req.isAuthenticated())
          return next();
  
      // if they aren't redirect them to the home page
      res.redirect('/');
  }
  </code></pre>
  
  <p>server.js</p>
  
  <pre><code>// modules =================================================
  var express        = require('express');
  var app            = express();
  var mongoose       = require('mongoose');
  var bodyParser     = require('body-parser');
  var methodOverride = require('method-override');
  var db = require('./config/db');
  var passport = require('passport');
  var port = process.env.PORT || 8080; 
  mongoose.connect(db.url); 
  app.use(bodyParser.json()); 
  app.use(bodyParser.json({ type: 'application/vnd.api+json' })); // parse application/vnd.api+json as json
  app.use(bodyParser.urlencoded({ extended: true })); // parse application/x-www-form-urlencoded
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(methodOverride('X-HTTP-Method-Override')); // override with the X-HTTP-Method-Override header in the request. simulate DELETE/PUT
  app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users
  
  // routes ==================================================
  require('./app/routes')(app); // pass our application into our routes
  
  // start app ===============================================
  app.listen(port);   
  console.log('Magic happens on port ' + port);           // shoutout to the user
  exports = module.exports = app;                         // expose app
  </code></pre>