aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/app.js
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-05-10 21:37:13 +0200
committerDennis Eriksen <dennis.se@gmail.com>2013-05-10 21:37:13 +0200
commit30b52729b50531e818e79a4e5722ee5be95de49d (patch)
treef5def87bcdadbc920d14109a10f97df608080720 /app.js
parentadded express-validator middleware (diff)
downloadDivid-30b52729b50531e818e79a4e5722ee5be95de49d.tar.gz
just some cleaning up
Diffstat (limited to 'app.js')
-rw-r--r--app.js10
1 files changed, 10 insertions, 0 deletions
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);
});