...
|
...
|
@@ -7,26 +7,29 @@ |
|
|
|
|
|
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 session = require('cookie-session');
|
|
|
const session = require('yoho-express-session');
|
|
|
|
|
|
const memcached = require('connect-memcached');
|
|
|
const hbs = require('express-handlebars');
|
|
|
const pkg = require('./package.json');
|
|
|
|
|
|
const yohoLib = require('yoho-node-lib');
|
|
|
|
|
|
const app = express();
|
|
|
|
|
|
const MemcachedStore = memcached(session);
|
|
|
|
|
|
// 全局注册library
|
|
|
yohoLib.global(config);
|
|
|
|
|
|
global.middleware = path.resolve('./doraemon/middleware');
|
|
|
global.utils = path.resolve('./utils');
|
|
|
|
...
|
...
|
@@ -35,17 +38,17 @@ app.locals.devEnv = app.get('env') === 'development'; |
|
|
app.locals.version = pkg.version;
|
|
|
|
|
|
app.set('subdomain offset', 2);
|
|
|
app.set('view engine', '.hbs');
|
|
|
app.set('views', './doraemon/views');
|
|
|
app.set('view cache', true);
|
|
|
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
|
|
|
}));
|
|
|
|
|
|
app.use(global.yoho.middleware());
|
|
|
|
|
|
app.use(favicon(path.join(__dirname, '/public/favicon.ico')));
|
|
|
app.use(express.static(path.join(__dirname, 'public')));
|
|
|
app.use(bodyParser.json());
|
...
|
...
|
|