Authored by 陈峰

Merge branch 'qCloud' of http://git.yoho.cn/fe/yohobuywap-node into qCloud

@@ -16,6 +16,7 @@ const path = require('path'); @@ -16,6 +16,7 @@ const path = require('path');
16 const bodyParser = require('body-parser'); 16 const bodyParser = require('body-parser');
17 const cookieParser = require('cookie-parser'); 17 const cookieParser = require('cookie-parser');
18 const favicon = require('serve-favicon'); 18 const favicon = require('serve-favicon');
  19 +const uuid = require('uuid');
19 20
20 const pkg = require('./package.json'); 21 const pkg = require('./package.json');
21 const session = require('cookie-session'); 22 const session = require('cookie-session');
@@ -66,6 +67,12 @@ app.use((req, res, next) => { @@ -66,6 +67,12 @@ app.use((req, res, next) => {
66 req.user = {}; // 全局的用户数据 67 req.user = {}; // 全局的用户数据
67 req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等 68 req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
68 69
  70 + if (!req.session.id) {
  71 + req.session.id = uuid.v4();
  72 + }
  73 +
  74 + req.sessionID = req.session.id;
  75 +
69 next(); 76 next();
70 }); 77 });
71 78
@@ -25,7 +25,7 @@ const praiseArticle = (req, res, next) => { @@ -25,7 +25,7 @@ const praiseArticle = (req, res, next) => {
25 /* 判断参数是否有效 */ 25 /* 判断参数是否有效 */
26 let id = req.body.id, 26 let id = req.body.id,
27 opt = req.body.opt || 'ok', 27 opt = req.body.opt || 'ok',
28 - udid = req.sessionID; 28 + udid = req.sessionID || require('md5')(req.ip) || 'yoho';
29 29
30 if (!stringProcess.isNumeric(id)) { 30 if (!stringProcess.isNumeric(id)) {
31 res.json({ code: 400, message: '非法请求', data: '' }); 31 res.json({ code: 400, message: '非法请求', data: '' });
@@ -17,10 +17,10 @@ module.exports = { @@ -17,10 +17,10 @@ module.exports = {
17 siteUrl: '//m.yohobuy.com', 17 siteUrl: '//m.yohobuy.com',
18 assetUrl: '//localhost:5001', 18 assetUrl: '//localhost:5001',
19 domains: { 19 domains: {
20 - api: 'http://api.yoho.cn/', 20 + api: 'http://api.yoho.cn/',
21 service: 'http://service.yoho.cn/', 21 service: 'http://service.yoho.cn/',
22 liveApi: 'http://api.live.yoho.cn/', 22 liveApi: 'http://api.live.yoho.cn/',
23 - singleApi: 'http://single.yoho.cn/' 23 + singleApi: 'http://single.yoho.cn/'
24 24
25 // api: 'http://api-test1.yohops.com:9999/', 25 // api: 'http://api-test1.yohops.com:9999/',
26 // service: 'http://service-test1.yohops.com:9999/', 26 // service: 'http://service-test1.yohops.com:9999/',
@@ -70,7 +70,7 @@ module.exports = { @@ -70,7 +70,7 @@ module.exports = {
70 port: 4444 // influxdb port 70 port: 4444 // influxdb port
71 }, 71 },
72 console: { 72 console: {
73 - level: 'error', 73 + level: isProduction ? 'error' : 'info',
74 colorize: 'all', 74 colorize: 'all',
75 prettyPrint: true 75 prettyPrint: true
76 } 76 }
@@ -45,7 +45,6 @@ @@ -45,7 +45,6 @@
45 "ava": "^0.16.0", 45 "ava": "^0.16.0",
46 "babel-preset-es2015": "^6.14.0", 46 "babel-preset-es2015": "^6.14.0",
47 "babel-register": "^6.14.0", 47 "babel-register": "^6.14.0",
48 - "cheerio": "^0.22.0",  
49 "eslint": "^3.0.1", 48 "eslint": "^3.0.1",
50 "eslint-config-yoho": "^1.0.1", 49 "eslint-config-yoho": "^1.0.1",
51 "gulp": "^3.9.1", 50 "gulp": "^3.9.1",