fix logging and config
This commit is contained in:
parent
0e5e20c09c
commit
28aeac6f9b
@ -3,9 +3,10 @@
|
|||||||
/**
|
/**
|
||||||
* Module dependencies.
|
* Module dependencies.
|
||||||
*/
|
*/
|
||||||
var express = require('express'),
|
var express = require('express');
|
||||||
config = require('./config'),
|
var config = require('./config');
|
||||||
path = require('path');
|
var path = require('path');
|
||||||
|
var logger = require('../lib/logger').logger;
|
||||||
|
|
||||||
module.exports = function(app, historicSync, peerSync) {
|
module.exports = function(app, historicSync, peerSync) {
|
||||||
|
|
||||||
@ -22,11 +23,8 @@ module.exports = function(app, historicSync, peerSync) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
app.set('showStackError', true);
|
app.set('showStackError', true);
|
||||||
|
|
||||||
// Compress JSON outputs
|
|
||||||
app.set('json spaces', 0);
|
app.set('json spaces', 0);
|
||||||
|
|
||||||
//Enable jsonp
|
|
||||||
app.enable('jsonp callback');
|
app.enable('jsonp callback');
|
||||||
app.use(config.apiPrefix + '/sync', setHistoric);
|
app.use(config.apiPrefix + '/sync', setHistoric);
|
||||||
app.use(config.apiPrefix + '/peer', setPeer);
|
app.use(config.apiPrefix + '/peer', setPeer);
|
||||||
@ -38,12 +36,10 @@ module.exports = function(app, historicSync, peerSync) {
|
|||||||
|
|
||||||
if (config.publicPath) {
|
if (config.publicPath) {
|
||||||
var staticPath = path.normalize(config.rootPath + '/../' + config.publicPath);
|
var staticPath = path.normalize(config.rootPath + '/../' + config.publicPath);
|
||||||
|
|
||||||
//IMPORTANT: for html5mode, this line must to be before app.router
|
//IMPORTANT: for html5mode, this line must to be before app.router
|
||||||
app.use(express.static(staticPath));
|
app.use(express.static(staticPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
// manual helpers
|
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
app.locals.config = config;
|
app.locals.config = config;
|
||||||
next();
|
next();
|
||||||
@ -52,15 +48,10 @@ module.exports = function(app, historicSync, peerSync) {
|
|||||||
//routes should be at the last
|
//routes should be at the last
|
||||||
app.use(app.router);
|
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) {
|
app.use(function(err, req, res, next) {
|
||||||
//Treat as 404
|
|
||||||
if (~err.message.indexOf('not found')) return next();
|
if (~err.message.indexOf('not found')) return next();
|
||||||
|
|
||||||
//Log it
|
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
|
|
||||||
//Error page
|
|
||||||
res.status(500).jsonp({
|
res.status(500).jsonp({
|
||||||
status: 500,
|
status: 500,
|
||||||
error: err.stack
|
error: err.stack
|
||||||
|
|||||||
11
insight.js
11
insight.js
@ -94,10 +94,7 @@ var walk = function(path) {
|
|||||||
|
|
||||||
walk(models_path);
|
walk(models_path);
|
||||||
|
|
||||||
/**
|
// p2pSync process
|
||||||
* p2pSync process
|
|
||||||
*/
|
|
||||||
|
|
||||||
var peerSync = new PeerSync({
|
var peerSync = new PeerSync({
|
||||||
shouldBroadcast: true
|
shouldBroadcast: true
|
||||||
});
|
});
|
||||||
@ -106,9 +103,7 @@ if (!config.disableP2pSync) {
|
|||||||
peerSync.run();
|
peerSync.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// historic_sync process
|
||||||
* historic_sync process
|
|
||||||
*/
|
|
||||||
var historicSync = new HistoricSync({
|
var historicSync = new HistoricSync({
|
||||||
shouldBroadcastSync: true
|
shouldBroadcastSync: true
|
||||||
});
|
});
|
||||||
@ -143,8 +138,8 @@ if (config.enableMailbox) {
|
|||||||
|
|
||||||
|
|
||||||
// express settings
|
// express settings
|
||||||
require('./config/routes')(expressApp);
|
|
||||||
require('./config/express')(expressApp, historicSync, peerSync);
|
require('./config/express')(expressApp, historicSync, peerSync);
|
||||||
|
require('./config/routes')(expressApp);
|
||||||
|
|
||||||
|
|
||||||
//Start the app by listening on <port>
|
//Start the app by listening on <port>
|
||||||
|
|||||||
@ -32,5 +32,4 @@ module.exports.init = function(app, config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user