Authored by 姜枫

修改之前的代码测试使用lib module

@@ -21,6 +21,7 @@ const session = require('yoho-express-session'); @@ -21,6 +21,7 @@ const session = require('yoho-express-session');
21 const memcached = require('yoho-connect-memcached'); 21 const memcached = require('yoho-connect-memcached');
22 const uuid = require('uuid'); 22 const uuid = require('uuid');
23 const _ = require('lodash'); 23 const _ = require('lodash');
  24 +const yohoLib = require('yoho-node-lib');
24 const pkg = require('./package.json'); 25 const pkg = require('./package.json');
25 26
26 const app = express(); 27 const app = express();
@@ -31,8 +32,8 @@ const MemcachedStore = memcached(session); @@ -31,8 +32,8 @@ const MemcachedStore = memcached(session);
31 app.locals.devEnv = app.get('env') === 'development'; 32 app.locals.devEnv = app.get('env') === 'development';
32 app.locals.version = pkg.version; 33 app.locals.version = pkg.version;
33 34
34 -// 指定libray目录  
35 -global.library = path.resolve('./library/'); 35 +// 全局注册library
  36 +yohoLib.global(config);
36 37
37 app.set('view engine', '.hbs'); 38 app.set('view engine', '.hbs');
38 39
@@ -4,11 +4,11 @@ @@ -4,11 +4,11 @@
4 * @date: 2016/05/09 4 * @date: 2016/05/09
5 */ 5 */
6 'use strict'; 6 'use strict';
7 -const library = '../../../library';  
8 const _ = require('lodash'); 7 const _ = require('lodash');
9 const channelModel = require('../models/channel'); 8 const channelModel = require('../models/channel');
10 -const helpers = require(`${library}/helpers`);  
11 -const log = require(`${library}/logger`); 9 +
  10 +const helpers = global.yoho.helpers;
  11 +const log = global.yoho.logger;
12 12
13 const renderData = { 13 const renderData = {
14 module: 'channel', 14 module: 'channel',
@@ -24,7 +24,7 @@ app.engine('.hbs', hbs({ @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
24 defaultLayout: 'layout', 24 defaultLayout: 'layout',
25 layoutsDir: doraemon, 25 layoutsDir: doraemon,
26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], 26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
27 - helpers: require(`${global.library}/helpers`) 27 + helpers: global.yoho.helpers
28 })); 28 }));
29 29
30 // router 30 // router
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 defaultLayout: 'layout', 24 defaultLayout: 'layout',
25 layoutsDir: doraemon, 25 layoutsDir: doraemon,
26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], 26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
27 - helpers: require(`${global.library}/helpers`) 27 + helpers: global.yoho.helpers
28 })); 28 }));
29 29
30 // router 30 // router
@@ -15,8 +15,7 @@ const logger = new (winston.Logger)({ @@ -15,8 +15,7 @@ const logger = new (winston.Logger)({
15 transports: [ 15 transports: [
16 new (FileTransport)(config.loggers.infoFile), 16 new (FileTransport)(config.loggers.infoFile),
17 new (FileTransport)(config.loggers.errorFile), 17 new (FileTransport)(config.loggers.errorFile),
18 - new (winston.transports.UdpTransport)(config.loggers.udp),  
19 - new (winston.transports.Console)(config.loggers.console) 18 + new (winston.transports.UdpTransport)(config.loggers.udp)
20 ], 19 ],
21 exitOnError: false 20 exitOnError: false
22 }); 21 });
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 "express": "^4.13.1", 37 "express": "^4.13.1",
38 "express-handlebars": "^3.0.0", 38 "express-handlebars": "^3.0.0",
39 "influxdb-winston": "^1.0.1", 39 "influxdb-winston": "^1.0.1",
40 - "lodash": "^4.12.0", 40 + "lodash": "^4.13.1",
41 "md5": "^2.1.0", 41 "md5": "^2.1.0",
42 "memcached": "^2.2.1", 42 "memcached": "^2.2.1",
43 "moment": "^2.13.0", 43 "moment": "^2.13.0",
@@ -49,7 +49,8 @@ @@ -49,7 +49,8 @@
49 "winston": "^2.2.0", 49 "winston": "^2.2.0",
50 "winston-daily-rotate-file": "^1.0.1", 50 "winston-daily-rotate-file": "^1.0.1",
51 "yoho-connect-memcached": "^1.0.3", 51 "yoho-connect-memcached": "^1.0.3",
52 - "yoho-express-session": "^1.0.3" 52 + "yoho-express-session": "^1.0.3",
  53 + "yoho-node-lib": "0.0.2"
53 }, 54 },
54 "devDependencies": { 55 "devDependencies": {
55 "autoprefixer": "^6.3.6", 56 "autoprefixer": "^6.3.6",