Skip to content

Commit

Permalink
updating to express4, morgan console logger, mongoose 3.8,body-parser…
Browse files Browse the repository at this point in the history
… and method-override
  • Loading branch information
caionitro committed Jul 15, 2014
1 parent c53b479 commit 81e5eed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"main" : "server.js",
"author" : "Scotch",
"dependencies" : {
"express" : "~3.4.4",
"mongoose" : "~3.6.2"
"express" : "~4.6.1",
"mongoose" : "~3.8.13",
"morgan" : "~1.1.1",
"body-parser" : "~1.4.3",
"method-override" : "~2.1.1"
}
}
16 changes: 10 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ var app = express(); // create our app w/ express
var mongoose = require('mongoose'); // mongoose for mongodb
var port = process.env.PORT || 8080; // set the port
var database = require('./config/database'); // load the database config
var morgan = require('morgan');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');

// configuration ===============================================================
mongoose.connect(database.url); // connect to mongoDB database on modulus.io

app.configure(function() {
app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users
app.use(express.logger('dev')); // log every request to the console
app.use(express.bodyParser()); // pull information from html in POST
app.use(express.methodOverride()); // simulate DELETE and PUT
});
app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users
app.use(morgan()); // log every request to the console
app.use(bodyParser.urlencoded({'extended':'true'})); // parse application/x-www-form-urlencoded
app.use(bodyParser.json()); // parse application/json
app.use(bodyParser.json({ type: 'application/vnd.api+json' })); // parse application/vnd.api+json as json
app.use(methodOverride('X-HTTP-Method-Override')); // override with the X-HTTP-Method-Override header in the request


// routes ======================================================================
require('./app/routes.js')(app);
Expand Down

0 comments on commit 81e5eed

Please sign in to comment.