its because you have declared the middleware after you have intialised the routes
in the index file
the correct order is
app.use(passport.initialize());
app.use(passport.session());
app.use(passport.setAuthenticatedUser);
app.use('/', require('./routes'));