...
|
...
|
@@ -40,6 +40,8 @@ app.locals.startTime = moment().format('YYYYMMDDHH'); |
|
|
// 全局注册library
|
|
|
yohoLib.global(config);
|
|
|
|
|
|
const logger = global.yoho.logger;
|
|
|
|
|
|
// zookeeper
|
|
|
if (config.zookeeperServer) {
|
|
|
require('yoho-zookeeper')(config.zookeeperServer, 'wap', app.locals.wap = {}, global.yoho.cache);
|
...
|
...
|
@@ -52,6 +54,23 @@ app.set('etag', false); |
|
|
|
|
|
app.enable('trust proxy');
|
|
|
|
|
|
const safeStringify = require('fast-safe-stringify');
|
|
|
|
|
|
// 循环对象检测
|
|
|
app.set('json replacer', function(key, value) {
|
|
|
if (!key) {
|
|
|
let safeStr = safeStringify(value);
|
|
|
|
|
|
if (/\[Circular\]/.test(safeStr)) {
|
|
|
logger.error('stringify error:', value);
|
|
|
}
|
|
|
|
|
|
return JSON.parse(safeStr);
|
|
|
}
|
|
|
|
|
|
return value;
|
|
|
});
|
|
|
|
|
|
// 请求限制中间件
|
|
|
if (!app.locals.devEnv) {
|
|
|
app.use(require('./doraemon/middleware/limiter'));
|
...
|
...
|
@@ -60,8 +79,6 @@ if (!app.locals.devEnv) { |
|
|
// 指定libray目录
|
|
|
global.utils = path.resolve('./utils');
|
|
|
|
|
|
const logger = global.yoho.logger;
|
|
|
|
|
|
// 访问域名层级
|
|
|
app.set('subdomain offset', 3);
|
|
|
app.use(global.yoho.hbs({
|
...
|
...
|
|