diff --git a/config/express.js b/config/express.js index d61bf61..20da68f 100644 --- a/config/express.js +++ b/config/express.js @@ -3,9 +3,10 @@ /** * Module dependencies. */ -var express = require('express'), - config = require('./config'), - path = require('path'); +var express = require('express'); +var config = require('./config'); +var path = require('path'); +var logger = require('../lib/logger').logger; module.exports = function(app, historicSync, peerSync) { @@ -22,11 +23,8 @@ module.exports = function(app, historicSync, peerSync) { }; app.set('showStackError', true); - - // Compress JSON outputs app.set('json spaces', 0); - //Enable jsonp app.enable('jsonp callback'); app.use(config.apiPrefix + '/sync', setHistoric); app.use(config.apiPrefix + '/peer', setPeer); @@ -38,12 +36,10 @@ module.exports = function(app, historicSync, peerSync) { if (config.publicPath) { var staticPath = path.normalize(config.rootPath + '/../' + config.publicPath); - //IMPORTANT: for html5mode, this line must to be before app.router app.use(express.static(staticPath)); } - // manual helpers app.use(function(req, res, next) { app.locals.config = config; next(); @@ -52,15 +48,10 @@ module.exports = function(app, historicSync, peerSync) { //routes should be at the last app.use(app.router); - //Assume "not found" in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc. + //Assume "not found" in the error msgs is a 404 app.use(function(err, req, res, next) { - //Treat as 404 if (~err.message.indexOf('not found')) return next(); - - //Log it console.error(err.stack); - - //Error page res.status(500).jsonp({ status: 500, error: err.stack diff --git a/insight.js b/insight.js index d9ee63f..5fd9011 100755 --- a/insight.js +++ b/insight.js @@ -94,10 +94,7 @@ var walk = function(path) { walk(models_path); -/** - * p2pSync process - */ - +// p2pSync process var peerSync = new PeerSync({ shouldBroadcast: true }); @@ -106,9 +103,7 @@ if (!config.disableP2pSync) { peerSync.run(); } -/** - * historic_sync process - */ +// historic_sync process var historicSync = new HistoricSync({ shouldBroadcastSync: true }); @@ -143,8 +138,8 @@ if (config.enableMailbox) { // express settings -require('./config/routes')(expressApp); require('./config/express')(expressApp, historicSync, peerSync); +require('./config/routes')(expressApp); //Start the app by listening on diff --git a/plugins/ratelimiter.js b/plugins/ratelimiter.js index 0da5e2d..6523673 100644 --- a/plugins/ratelimiter.js +++ b/plugins/ratelimiter.js @@ -32,5 +32,4 @@ module.exports.init = function(app, config) { } } })); - };