diff --git a/index.js b/index.js index a37cb8f..0f49d44 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,10 @@ var utils = require( 'utils' ) + , parser = require( 'body-parser' ) + , compress = require( 'compression' ) + , override = require( 'method-override' ) + , resTime = require( 'response-time' ) + , timeout = require( 'connect-timeout' ) + , logger = require( 'morgan' ) , env = utils.bootstrapEnv() , moduleLdr = env.moduleLoader , cors = require( 'cors' ) @@ -12,15 +18,13 @@ debug( 'started with pid %s', chalk.yellow( process.pid ) ); moduleLdr.on( 'preLoadModules', function() { debug( 'Configuring express application...' ); - app.configure(function() { - app.use( express.urlencoded() ); - app.use( express.json() ); - app.use( express.logger('dev') ); - app.use( express.compress() ); - app.use( express.favicon() ); - app.use( express.methodOverride() ); - app.use( cors( env.config.cors ) ); - }); + app.use( timeout( '30s' ) ); + app.use( parser.urlencoded( { extended: true } ) ); + app.use( parser.json() ); + app.use( logger( 'dev' ) ); + app.use( compress() ); + app.use( override() ); + app.use( cors( env.config.cors ) ); }); moduleLdr.on( 'modulesLoaded', function() { @@ -32,11 +36,8 @@ moduleLdr.on( 'modulesLoaded', function() { moduleLdr.on( 'routesInitialized', function() { debug( 'Setting up router and starting http server...' ); - app.configure(function() { - app.use( app.router ); - app.listen( env.webPort, function() { - debug( 'Started web server on port %s in enviromment %s', chalk.yellow( env.webPort ), chalk.yellow( process.env.NODE_ENV ? process.env.NODE_ENV : "LOCAL" ) ); - }); + app.listen( env.webPort, function() { + debug( 'Started web server on port %s in enviromment %s', chalk.yellow( env.webPort ), chalk.yellow( process.env.NODE_ENV ? process.env.NODE_ENV : "LOCAL" ) ); }); }); diff --git a/lib/utils/moduleLoader.js b/lib/utils/moduleLoader.js index 0eed766..36cbf9c 100644 --- a/lib/utils/moduleLoader.js +++ b/lib/utils/moduleLoader.js @@ -132,7 +132,7 @@ var ModuleLoader = module.exports = Class.extend( module.debug( 'Module.configureApp() hook...' ); module.on( 'appReady', callback ); - injector.getInstance( 'app' ).configure( module.proxy( 'configureApp', injector.getInstance( 'app' ), injector.getInstance( 'express' ) ) ); + module.proxy( 'configureApp', injector.getInstance( 'app' ), injector.getInstance( 'express' ) )(); } else { callback( null ); } diff --git a/package.json b/package.json index 463f8b4..6a7b2bf 100644 --- a/package.json +++ b/package.json @@ -36,17 +36,22 @@ "dependencies": { "async": "~0.9.0", "bluebird": "~2.9.2", + "body-parser": "~1.10.2", "chalk": "~0.5.1", "clever-controller": "~1.1.6", "clever-injector": "~1.0.2", + "compression": "~1.3.0", "cors": "~2.5.2", "debug": "~2.1.0", "deepmerge": "~0.2.7", "ejs": "~2.2.3", - "express": "~3.4.7", + "express": "~4.11.1", "i": "~0.3.2", "matchdep": "~0.3.0", + "method-override": "~2.3.1", + "morgan": "~1.5.1", "nconf": "~0.6.9", + "response-time": "~2.2.0", "sendgrid": "~1.5.0", "uberclass": "~1.0.1", "underscore": "~1.7.0",