...
|
...
|
@@ -10,9 +10,18 @@ var express = require('express'), |
|
|
|
|
|
var logger = require('morgan'),
|
|
|
favicon = require('serve-favicon'),
|
|
|
cookieParser = require('cookie-parser');
|
|
|
cookieParser = require('cookie-parser'),
|
|
|
session = require('express-session'),
|
|
|
connectRedis = require('connect-redis');
|
|
|
|
|
|
var app = express();
|
|
|
var config = require('./config');
|
|
|
|
|
|
var app = express(),
|
|
|
RedisStore = connectRedis(session);
|
|
|
|
|
|
if (app.get('env') === 'development') {
|
|
|
config = Object.assign(config, require('./config.dev'));
|
|
|
}
|
|
|
|
|
|
app.set('views', path.join(__dirname, 'views'));
|
|
|
app.set('view engine', 'hbs');
|
...
|
...
|
@@ -24,7 +33,18 @@ app.use(bodyParser.urlencoded({ extended: false })); |
|
|
app.use(cookieParser());
|
|
|
app.use(express.static(path.join(__dirname, 'public')));
|
|
|
|
|
|
// session 配置
|
|
|
app.use(session({
|
|
|
name: 'yoho-activity',
|
|
|
resave: true,
|
|
|
saveUninitialized: true,
|
|
|
store: new RedisStore(config.sessionRedis),
|
|
|
secret: config.sessionSecret
|
|
|
}));
|
|
|
|
|
|
app.use(function(req, res, next) {
|
|
|
|
|
|
// console.log(req.session);
|
|
|
res.locals.isDevelop = app.get('env') === 'development';
|
|
|
next();
|
|
|
});
|
...
|
...
|
|