diff --git a/app/templates/server/app.js b/app/templates/server/app.js index 44678b01b..02593347b 100644 --- a/app/templates/server/app.js +++ b/app/templates/server/app.js @@ -24,17 +24,11 @@ var socketio = require('socket.io').listen(server); require('./config/socketio')(socketio);<% } %> require('./config/express')(app); require('./routes')(app); -<% if (filters.twitterAuth) { %> -mongoose.connection.on('connected', function () { - // Start server - server.listen(config.port, config.ip, function() { - console.log('Express server listening on %d, in %s mode', config.port, app.get('env')); - }); -});<% } else { %> + // Start server server.listen(config.port, config.ip, function () { console.log('Express server listening on %d, in %s mode', config.port, app.get('env')); -});<% } %> +}); // Expose app exports = module.exports = app; \ No newline at end of file diff --git a/app/templates/server/config/express.js b/app/templates/server/config/express.js index 9bef453b0..59880194a 100644 --- a/app/templates/server/config/express.js +++ b/app/templates/server/config/express.js @@ -33,17 +33,15 @@ module.exports = function(app) { app.use(cookieParser()); <% if (filters.auth) { %>app.use(passport.initialize());<% } %><% if (filters.twitterAuth) { %> - mongoose.connection.on('connected', function () { - // Persist sessions with mongoStore - // We need to enable sessions for passport twitter because its an oauth 1.0 strategy - app.use(session({ - secret: config.secrets.session, - resave: true, - saveUninitialized: true, - store: new mongoStore({ mongoose_connection: mongoose.connection }) - })); - });<% } %> - + // Persist sessions with mongoStore + // We need to enable sessions for passport twitter because its an oauth 1.0 strategy + app.use(session({ + secret: config.secrets.session, + resave: true, + saveUninitialized: true, + store: new mongoStore({ mongoose_connection: mongoose.connection }) + })); + <% } %> if ('production' === env) { app.use(favicon(path.join(config.root, 'public', 'favicon.ico'))); app.use(express.static(path.join(config.root, 'public')));