Authored by 姜枫

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

... ... @@ -21,6 +21,7 @@ const session = require('yoho-express-session');
const memcached = require('yoho-connect-memcached');
const uuid = require('uuid');
const _ = require('lodash');
const yohoLib = require('yoho-node-lib');
const pkg = require('./package.json');
const app = express();
... ... @@ -31,8 +32,8 @@ const MemcachedStore = memcached(session);
app.locals.devEnv = app.get('env') === 'development';
app.locals.version = pkg.version;
// 指定libray目录
global.library = path.resolve('./library/');
// 全局注册library
yohoLib.global(config);
app.set('view engine', '.hbs');
... ...
... ... @@ -4,11 +4,11 @@
* @date: 2016/05/09
*/
'use strict';
const library = '../../../library';
const _ = require('lodash');
const channelModel = require('../models/channel');
const helpers = require(`${library}/helpers`);
const log = require(`${library}/logger`);
const helpers = global.yoho.helpers;
const log = global.yoho.logger;
const renderData = {
module: 'channel',
... ...
... ... @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: require(`${global.library}/helpers`)
helpers: global.yoho.helpers
}));
// router
... ...
... ... @@ -24,7 +24,7 @@
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: require(`${global.library}/helpers`)
helpers: global.yoho.helpers
}));
// router
... ...
... ... @@ -15,8 +15,7 @@ const logger = new (winston.Logger)({
transports: [
new (FileTransport)(config.loggers.infoFile),
new (FileTransport)(config.loggers.errorFile),
new (winston.transports.UdpTransport)(config.loggers.udp),
new (winston.transports.Console)(config.loggers.console)
new (winston.transports.UdpTransport)(config.loggers.udp)
],
exitOnError: false
});
... ...
... ... @@ -37,7 +37,7 @@
"express": "^4.13.1",
"express-handlebars": "^3.0.0",
"influxdb-winston": "^1.0.1",
"lodash": "^4.12.0",
"lodash": "^4.13.1",
"md5": "^2.1.0",
"memcached": "^2.2.1",
"moment": "^2.13.0",
... ... @@ -49,7 +49,8 @@
"winston": "^2.2.0",
"winston-daily-rotate-file": "^1.0.1",
"yoho-connect-memcached": "^1.0.3",
"yoho-express-session": "^1.0.3"
"yoho-express-session": "^1.0.3",
"yoho-node-lib": "0.0.2"
},
"devDependencies": {
"autoprefixer": "^6.3.6",
... ...