|
@@ -13,6 +13,8 @@ const bodyParser = require('body-parser'); |
|
@@ -13,6 +13,8 @@ const bodyParser = require('body-parser'); |
13
|
const cookieParser = require('cookie-parser');
|
13
|
const cookieParser = require('cookie-parser');
|
14
|
const favicon = require('serve-favicon');
|
14
|
const favicon = require('serve-favicon');
|
15
|
const session = require('yoho-express-session');
|
15
|
const session = require('yoho-express-session');
|
|
|
16
|
+const _ = require('lodash');
|
|
|
17
|
+const fp = require('lodash/fp');
|
16
|
|
18
|
|
17
|
const memcached = require('connect-memcached');
|
19
|
const memcached = require('connect-memcached');
|
18
|
const hbs = require('express-handlebars');
|
20
|
const hbs = require('express-handlebars');
|
|
@@ -27,15 +29,24 @@ const MemcachedStore = memcached(session); |
|
@@ -27,15 +29,24 @@ const MemcachedStore = memcached(session); |
27
|
// 全局注册library
|
29
|
// 全局注册library
|
28
|
yohoLib.global(config);
|
30
|
yohoLib.global(config);
|
29
|
|
31
|
|
|
|
32
|
+const helpers = global.yoho.helpers;
|
|
|
33
|
+
|
|
|
34
|
+// NOTE: 这里修改了图片质量的参数
|
|
|
35
|
+helpers.image = _.flow(helpers.image, fp.replace(/\/quality\/\d*$/, '/quality/90'));
|
|
|
36
|
+helpers.json = JSON.stringify;
|
|
|
37
|
+
|
30
|
global.middleware = path.resolve('./doraemon/middleware');
|
38
|
global.middleware = path.resolve('./doraemon/middleware');
|
31
|
global.utils = path.resolve('./utils');
|
39
|
global.utils = path.resolve('./utils');
|
32
|
|
40
|
|
33
|
// 向模板注入变量
|
41
|
// 向模板注入变量
|
34
|
app.locals.devEnv = app.get('env') === 'development';
|
42
|
app.locals.devEnv = app.get('env') === 'development';
|
35
|
app.locals.version = pkg.version;
|
43
|
app.locals.version = pkg.version;
|
|
|
44
|
+app.locals.__YOHO_CONFIG = {};
|
36
|
|
45
|
|
37
|
// zookeeper设置
|
46
|
// zookeeper设置
|
38
|
-require('yoho-zookeeper')(config.zookeeperServer, 'pc', app.locals);
|
47
|
+require('yoho-zookeeper')(config.zookeeperServer, 'pc', app.locals.__YOHO_CONFIG);
|
|
|
48
|
+console.log(app.locals.__YOHO_CONFIG);
|
|
|
49
|
+
|
39
|
|
50
|
|
40
|
app.set('subdomain offset', 2);
|
51
|
app.set('subdomain offset', 2);
|
41
|
app.set('view engine', '.hbs');
|
52
|
app.set('view engine', '.hbs');
|