From ba392d7dd9a880ebe22e47544a9e88465235710c Mon Sep 17 00:00:00 2001 From: Joel Holder Date: Thu, 16 Apr 2015 02:49:15 +0000 Subject: [PATCH 1/2] refactored app and modules to work with Express 4 --- app.js | 43 ++++++++++++++++++++++--------------------- package.json | 4 +++- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/app.js b/app.js index 4d2267e..ac48bc8 100644 --- a/app.js +++ b/app.js @@ -6,30 +6,31 @@ var express = require('express') , stylus = require('stylus') , redis = require('redis') - , http = require('http'); + , http = require('http') + , logger = require('morgan') + , errorHandler = require('errorhandler'); app = express(); -app.configure(function(){ - app.db = redis.createClient(); - app.set('views', __dirname + '/views'); - app.set('view engine', 'jade'); - app.set('phantom', 'phantomjs'); - app.set('screenshots', '/tmp'); - app.set('default viewport width', 1024); - app.set('default viewport height', 600); - app.set('colors', 3); - app.set('root', __dirname); - app.use(express.favicon()); - app.use(express.logger('dev')); - app.use(stylus.middleware({ src: __dirname + '/public' })); - app.use(express.static(__dirname + '/public')); - app.use(app.router); -}); - -app.configure('development', function(){ - app.use(express.errorHandler()); -}); + +app.db = redis.createClient(); +app.set('views', __dirname + '/views'); +app.set('view engine', 'jade'); +app.set('phantom', 'phantomjs'); +app.set('screenshots', '/tmp'); +app.set('default viewport width', 1024); +app.set('default viewport height', 600); +app.set('colors', 3); +app.set('root', __dirname); +app.use(logger); +app.use(stylus.middleware({ src: __dirname + '/public' })); +app.use(express.static(__dirname + '/public')); + + + + +app.use(errorHandler()); + require('./routes'); diff --git a/package.json b/package.json index 54767c7..cabd4a2 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,11 @@ "express": "https://github.com/visionmedia/express/tarball/master" , "jade": "*" , "palette": "*" + , "morgan": "*" + , "errorhandler": "*" , "redis": "0.7.x" , "canvas": "~1.1.2" , "stylus": "0.21.x" , "phantomjs": "~1.9.2" } -} \ No newline at end of file +} From 383ac62297efba2d7f7476d3351a35eccdd9909d Mon Sep 17 00:00:00 2001 From: Joel Holder Date: Thu, 16 Apr 2015 04:06:40 +0000 Subject: [PATCH 2/2] logging bug fix was hanging requests. added 'dev' console output to address this. tested and works as expected now. --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index ac48bc8..b336dee 100644 --- a/app.js +++ b/app.js @@ -22,7 +22,7 @@ app.set('default viewport width', 1024); app.set('default viewport height', 600); app.set('colors', 3); app.set('root', __dirname); -app.use(logger); +app.use(logger('dev')); app.use(stylus.middleware({ src: __dirname + '/public' })); app.use(express.static(__dirname + '/public'));