...
|
...
|
@@ -7,19 +7,23 @@ |
|
|
|
|
|
const config = require('./config/common');
|
|
|
|
|
|
global.Promise = require('bluebird');
|
|
|
|
|
|
const yohoLib = require('yoho-node-lib');
|
|
|
|
|
|
// 全局注册library
|
|
|
yohoLib.global(config);
|
|
|
|
|
|
const express = require('express');
|
|
|
const path = require('path');
|
|
|
const bodyParser = require('body-parser');
|
|
|
const cookieParser = require('cookie-parser');
|
|
|
const favicon = require('serve-favicon');
|
|
|
const yohoLib = require('yoho-node-lib');
|
|
|
const session = require('yoho-express-session');
|
|
|
const memcached = require('connect-memcached');
|
|
|
const hbs = require('express-handlebars');
|
|
|
|
|
|
const pkg = require('./package.json');
|
|
|
const session = require('cookie-session');
|
|
|
|
|
|
const app = express();
|
|
|
const MemcachedStore = memcached(session);
|
|
|
|
|
|
// 向模板注入变量
|
|
|
app.locals.devEnv = app.get('env') === 'development';
|
...
|
...
|
@@ -28,22 +32,18 @@ app.locals.version = pkg.version; |
|
|
// 访问域名层级
|
|
|
app.set('subdomain offset', 3);
|
|
|
|
|
|
// 全局注册library
|
|
|
yohoLib.global(config);
|
|
|
|
|
|
// 指定libray目录
|
|
|
global.utils = path.resolve('./utils');
|
|
|
|
|
|
const logger = global.yoho.logger;
|
|
|
|
|
|
app.set('subdomain offset', 3);
|
|
|
app.set('view engine', '.hbs');
|
|
|
app.set('views', './doraemon/views');
|
|
|
app.engine('.hbs', hbs({
|
|
|
app.use(global.yoho.hbs({
|
|
|
extname: '.hbs',
|
|
|
defaultLayout: 'layout',
|
|
|
layoutsDir: './doraemon/views',
|
|
|
partialsDir: './doraemon/views/partial',
|
|
|
layoutsDir: path.join(__dirname, 'doraemon/views'),
|
|
|
partialsDir: path.join(__dirname, 'doraemon/views/partial'),
|
|
|
views: path.join(__dirname, 'doraemon/views'),
|
|
|
helpers: global.yoho.helpers
|
|
|
}));
|
|
|
|
...
|
...
|
@@ -56,22 +56,8 @@ app.use(bodyParser.urlencoded({ |
|
|
app.use(cookieParser());
|
|
|
|
|
|
app.use(session({
|
|
|
proxy: true,
|
|
|
resave: false,
|
|
|
saveUninitialized: true,
|
|
|
unset: 'destroy',
|
|
|
secret: '82dd7e724f2c6870472c89dfa43cf48d',
|
|
|
name: 'yohobuy_session',
|
|
|
cookie: {
|
|
|
domain: 'yohobuy.com',
|
|
|
httpOnly: false
|
|
|
},
|
|
|
store: new MemcachedStore({
|
|
|
hosts: config.memcache.session,
|
|
|
prefix: 'yohobuy_session:',
|
|
|
timeout: 1000,
|
|
|
retries: 0
|
|
|
})
|
|
|
secret: '82dd7e724f2c6870472c89dfa43cf48d'
|
|
|
}));
|
|
|
|
|
|
app.use((req, res, next) => {
|
...
|
...
|
|