Authored by ccbikai(👎🏻🍜)

Merge branch 'hotfix/online-err'

... ... @@ -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({
... ...
... ... @@ -103,7 +103,7 @@ const getResources = (params, options) => {
let list = {};
let productSkns = [];
if (result.code !== 200) {
if (result && result.code !== 200) {
return data;
}
... ...
... ... @@ -233,7 +233,7 @@ const order = (params) => {
code: 200
}).then(result => {
if (result.data) {
if (result && result.data) {
Object.assign(finalResult, {cancelReason: result.data});
}
... ...
... ... @@ -74,8 +74,7 @@ exports.validate = (req, res, next) => {
captchaShow: true
};
logger.info(`captcha validate result${
captchaInput.toString() === captchaCode},user:${captchaInput};server:${captchaCode}`);
logger.info(`captcha validate result${(captchaInput && captchaInput.toString()) === captchaCode},user:${captchaInput};server:${captchaCode}`); // eslint-disable-line
_.set(req.session, 'captchaValidCount', errorCount - 1);
... ...
... ... @@ -18,7 +18,7 @@ exports.page = (req, res, next) => {
userApi.profile(req.user.uid)
.then(userinfo => {
userinfo = userinfo.data;
userinfo = userinfo.data || {};
res.render('chat/index', {
module: 'service',
... ... @@ -30,7 +30,7 @@ exports.page = (req, res, next) => {
imSocket: global.yoho.config.domains.imSocket,
userData: {
encrypteduid: crypto.encryption(null, uid + ''),
avatar: helpers.image(userinfo.head_ico, 100, 100),
avatar: userinfo.head_ico ? helpers.image(userinfo.head_ico, 100, 100) : '',
uname: userinfo.profile_name
}
});
... ...
... ... @@ -32,6 +32,7 @@
"connect-multiparty": "^2.0.0",
"cookie-parser": "^1.4.3",
"express": "^4.14.1",
"fast-safe-stringify": "^1.1.13",
"feed": "^1.0.2",
"geetest": "^4.1.1",
"lodash": "^4.17.4",
... ...