From 020dea057d5a0664caaeb041b18978237528f9a3 Mon Sep 17 00:00:00 2001 From: Chris Sevilleja Date: Sun, 4 May 2014 12:23:56 -0700 Subject: [PATCH] upgrading to express 4.0 --- package.json | 10 ++++++++-- server.js | 29 +++++++++++++++-------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 63c04ab..172feeb 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-authentication", "main": "server.js", "dependencies" : { - "express" : "~3.4.4", + "express" : "~4.0.0", "ejs" : "~0.8.5", "mongoose" : "~3.8.1", "passport" : "~0.1.17", @@ -11,6 +11,12 @@ "passport-twitter" : "~1.0.2", "passport-google-oauth" : "~0.1.5", "connect-flash" : "~0.1.1", - "bcrypt-nodejs" : "latest" + "bcrypt-nodejs" : "latest", + + "morgan": "~1.0.0", + "body-parser": "~1.0.0", + "cookie-parser": "~1.0.0", + "method-override": "~1.0.0", + "express-session": "~1.0.0" } } diff --git a/server.js b/server.js index 6a1c9ee..51cd05a 100644 --- a/server.js +++ b/server.js @@ -9,6 +9,11 @@ var mongoose = require('mongoose'); var passport = require('passport'); var flash = require('connect-flash'); +var morgan = require('morgan'); +var cookieParser = require('cookie-parser'); +var bodyParser = require('body-parser'); +var session = require('express-session'); + var configDB = require('./config/database.js'); // configuration =============================================================== @@ -16,22 +21,18 @@ mongoose.connect(configDB.url); // connect to our database require('./config/passport')(passport); // pass passport for configuration -app.configure(function() { - - // set up our express application - app.use(express.logger('dev')); // log every request to the console - app.use(express.cookieParser()); // read cookies (needed for auth) - app.use(express.bodyParser()); // get information from html forms - - app.set('view engine', 'ejs'); // set up ejs for templating +// set up our express application +app.use(morgan('dev')); // log every request to the console +app.use(cookieParser()); // read cookies (needed for auth) +app.use(bodyParser()); // get information from html forms - // required for passport - app.use(express.session({ secret: 'ilovescotchscotchyscotchscotch' })); // session secret - app.use(passport.initialize()); - app.use(passport.session()); // persistent login sessions - app.use(flash()); // use connect-flash for flash messages stored in session +app.set('view engine', 'ejs'); // set up ejs for templating -}); +// required for passport +app.use(session({ secret: 'ilovescotchscotchyscotchscotch' })); // session secret +app.use(passport.initialize()); +app.use(passport.session()); // persistent login sessions +app.use(flash()); // use connect-flash for flash messages stored in session // routes ====================================================================== require('./app/routes.js')(app, passport); // load our routes and pass in our app and fully configured passport