1its because you have declared the middleware after you have intialised the routes
2in the index file
3the correct order is
4app.use(passport.initialize());
5app.use(passport.session());
6app.use(passport.setAuthenticatedUser);
7
8
9app.use('/', require('./routes'));