代码拉取完成,页面将自动刷新
同步操作将从 ciey/NodeExpressAdmin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/****************************************************************************************
* app.js
* Node.js >= 8.0.0
* database : mysql, redis
* server : ubuntu 16.04 / nginx
***************************************************************************************/
'use strict';
const _ = require('lodash');
const path = require('path');
const config = require('./config');
const express = require('express');
require('express-async-errors');
const session = require('express-session');
const redisStore = require('connect-redis')(session);
const cookieParser = require('cookie-parser');
const compression = require('compression');
const bodyParser = require('body-parser');
const moment = require('moment');
const logger = require('./common/logger');
const requestLog = require('./middleware/requestLog');
const router = require('./router');
const app = express();
// view engine setup
app.engine('ejs', require('ejs-mate'));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// server static files
app.use('/assets', express.static(path.join(__dirname, 'assets')));
app.use('/upload/public', express.static(path.join(__dirname, 'upload/public')));
// log4js
app.use(require('log4js').connectLogger(logger, { level: config.debug ? 'DEBUG' : 'ERROR' }));
// Request logger
app.use(requestLog);
// parser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(compression());
// session support redis store
app.use(session({
store: new redisStore(config.redis),
resave: true,
saveUninitialized: false,
secret: config.session_secret
}));
// locals
app.use((req, res, next) => {
res.locals.user = req.session.user;
res.locals.moment = moment;
res.locals.site = config.site;
next();
});
// routes
app.use('/', router);
// error handle
app.use((err, req, res, next) => {
logger.error(err.message, err);
if (req.xhr) {
return res.json({
state: false,
msg: err.message
});
}
//return res.send(err.message);
next(err);
});
app.listen(config.port,() => {
logger.info('server listening on port:' + config.port);
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。