From 30b52729b50531e818e79a4e5722ee5be95de49d Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Fri, 10 May 2013 21:37:13 +0200 Subject: just some cleaning up --- app.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app.js') diff --git a/app.js b/app.js index a0f7ae1..d1911ee 100644 --- a/app.js +++ b/app.js @@ -2,19 +2,23 @@ /** * Module dependencies. */ + var express = require('express') , fs = require('fs') , passport = require('passport') , mongoose = require('mongoose'); + /** * App configuration */ + var port = process.env.PORT || 8000 , env = process.env.NODE_ENV || 'development' , config = require('./config/config')[env] , auth = require('./config/middlewares/authorization'); + // Bootstrap db connection mongoose.connect(config.db); var db = mongoose.connection; @@ -23,6 +27,7 @@ db.once('open', function callback(){ console.log('Connected to ' + config.db); }); + // Bootstrap models // This gets all model files in ./models var models_path = __dirname + '/models'; @@ -30,12 +35,15 @@ fs.readdirSync(models_path).forEach( function(file) { require(models_path + '/' + file); }); + // Bootstrap passport config require('./config/passport')(passport, config); + /** * Express */ + var app = express(); // express settings require('./config/express')(app, config, passport); @@ -44,12 +52,14 @@ require('./config/express')(app, config, passport); /** * Routes */ + require('./routes')(app, passport, auth); /** * Server initiation */ + app.listen(port, function() { console.log("Express server listening on port " + port); }); -- cgit v1.2.3