diff options
author | Dennis Eriksen <dennis.se@gmail.com> | 2013-05-10 21:37:13 +0200 |
---|---|---|
committer | Dennis Eriksen <dennis.se@gmail.com> | 2013-05-10 21:37:13 +0200 |
commit | 30b52729b50531e818e79a4e5722ee5be95de49d (patch) | |
tree | f5def87bcdadbc920d14109a10f97df608080720 /app.js | |
parent | added express-validator middleware (diff) | |
download | Divid-30b52729b50531e818e79a4e5722ee5be95de49d.tar.gz |
just some cleaning up
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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); }); |