From 06ea48caa58680bf0ab48ffadfa70b31fc615c0e Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Wed, 24 Apr 2013 23:00:34 +0200 Subject: set port to 3000 --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app.js') diff --git a/app.js b/app.js index 7fd9cbb..9fcfc31 100644 --- a/app.js +++ b/app.js @@ -17,7 +17,7 @@ var app = express(); // initiates express app.configure(function(){ // this controls the port the application will be running on. // by adding 'process.enc.PORT' we enable the app to run on automated systems like heroku - app.set('port', process.env.PORT || 8000); + app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); // sets views to the right directory app.set('view engine', 'ejs'); // initiates viewengine. We use EJS, or embedded js - http://embeddedjs.com/ -- cgit v1.2.3 From edd995fd5f92bba8221c7b9384ad0cb7c59794e3 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Thu, 25 Apr 2013 01:21:07 +0200 Subject: moved express config to own file. created configfile. --- app.js | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'app.js') diff --git a/app.js b/app.js index 9fcfc31..c292af9 100644 --- a/app.js +++ b/app.js @@ -5,45 +5,32 @@ var express = require('express') , path = require('path') - , bcrypt = require('bcrypt') , passport = require('passport'); + var app = express(); // initiates express /** * App configuration */ +var port = process.env.PORT || 3000 + , env = process.env.NODE_ENV || 'development' + , config = require('./config/config')[env]; -app.configure(function(){ - // this controls the port the application will be running on. - // by adding 'process.enc.PORT' we enable the app to run on automated systems like heroku - app.set('port', process.env.PORT || 3000); - - app.set('views', __dirname + '/views'); // sets views to the right directory - app.set('view engine', 'ejs'); // initiates viewengine. We use EJS, or embedded js - http://embeddedjs.com/ - app.use(express.favicon(__dirname + '/public/faviconb.ico')); // sets favicon - app.use(express.logger('dev')); - app.use(express.bodyParser()); - app.use(express.cookieParser()); - app.use(express.session({ secret: 'lsdrghoi4hgqio42nqf2uqi32f3bilu23fl23b' })); - app.use(express.methodOverride()); - app.use(require('less-middleware')({ src: __dirname + '/public' })); - app.use(express.static(path.join(__dirname, 'public'))); - app.use(passport.initialize()); - app.use(passport.session()); -}); -app.configure('development', function(){ - app.use(express.errorHandler()); -}); +/** + * Express + */ +var app = express(); +// express settings +require('./config/express')(app, config, passport); /** * Routes */ - -require('./router')(app); +require('./router')(app, config); @@ -51,8 +38,8 @@ require('./router')(app); * Server initiation */ -app.listen(app.get('port'), function() { - console.log("Express server listening on port " + app.get('port')); +app.listen(port, function() { + console.log("Express server listening on port " + port); }); -- cgit v1.2.3 From 9b5bf91eab12d6c1a5f88180288653f7056285f3 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Thu, 25 Apr 2013 01:24:22 +0200 Subject: test commit to dev branch --- app.js | 1 - 1 file changed, 1 deletion(-) (limited to 'app.js') diff --git a/app.js b/app.js index c292af9..67a1b13 100644 --- a/app.js +++ b/app.js @@ -33,7 +33,6 @@ require('./config/express')(app, config, passport); require('./router')(app, config); - /** * Server initiation */ -- cgit v1.2.3 From ed340574509eef6de3587c7191bb3977335319ce Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Thu, 25 Apr 2013 08:43:26 +0200 Subject: branch test --- app.js | 1 - 1 file changed, 1 deletion(-) (limited to 'app.js') diff --git a/app.js b/app.js index 67a1b13..2c93264 100644 --- a/app.js +++ b/app.js @@ -42,4 +42,3 @@ app.listen(port, function() { }); - -- cgit v1.2.3 From fc50b5b7f18d02ffa8056dc1edbd3bd43e973493 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Mon, 29 Apr 2013 03:39:15 +0200 Subject: been cleaning a bit, moving stuff to where it belongs. signup and signin works. --- app.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'app.js') diff --git a/app.js b/app.js index 86b2fb9..5bc039d 100644 --- a/app.js +++ b/app.js @@ -4,7 +4,7 @@ */ var express = require('express') - , path = require('path') + , fs = require('fs') , passport = require('passport'); @@ -13,10 +13,24 @@ var app = express(); // initiates express /** * App configuration */ -var port = process.env.PORT || 3000 +var port = process.env.PORT || 8000 , env = process.env.NODE_ENV || 'development' - , config = require('./config/config')[env]; + , config = require('./config/config')[env] + , auth = require('./config/middlewares/authorization') + , mongoose = require('mongoose'); +// Bootstrap db connection +mongoose.connect(config.db); + + +// Bootstrap models +var models_path = __dirname + '/models'; +fs.readdirSync(models_path).forEach( function(file) { + require(models_path + '/' + file); +}); + +// Bootstrap passport config +require('./config/passport')(passport, config); /** * Express @@ -29,7 +43,7 @@ require('./config/express')(app, config, passport); /** * Routes */ -require('./router')(app, config); +require('./router')(app, passport, auth); /** -- cgit v1.2.3 From c1371f712789e97fac6351daee93a048b12db69b Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Mon, 29 Apr 2013 04:13:18 +0200 Subject: cleaned up router.js --- app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app.js') diff --git a/app.js b/app.js index 5bc039d..3d7cef3 100644 --- a/app.js +++ b/app.js @@ -21,7 +21,11 @@ var port = process.env.PORT || 8000 // Bootstrap db connection mongoose.connect(config.db); - +var db = mongoose.connection; +db.on('error', console.error.bind(console, 'connection error:')); +db.once('open', function callback(){ + console.log('Connected to MongoDB'); +}); // Bootstrap models var models_path = __dirname + '/models'; -- cgit v1.2.3 From 3c4cbdb56ba0c4347069406b3fe014b1f7ca6f1f Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Mon, 29 Apr 2013 04:26:55 +0200 Subject: removed small bug where express is initiated twice. also cleaned a bit. --- app.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'app.js') diff --git a/app.js b/app.js index 3d7cef3..acbc3ff 100644 --- a/app.js +++ b/app.js @@ -2,14 +2,10 @@ /** * Module dependencies. */ - var express = require('express') , fs = require('fs') , passport = require('passport'); - -var app = express(); // initiates express - /** * App configuration */ @@ -53,9 +49,7 @@ require('./router')(app, passport, auth); /** * Server initiation */ - app.listen(port, function() { console.log("Express server listening on port " + port); }); - -- cgit v1.2.3