mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-08 06:55:26 +02:00
remove global middleware
This commit is contained in:
parent
7f8127813b
commit
2cfa4e36f8
2 changed files with 3 additions and 7 deletions
|
@ -22,11 +22,6 @@ app.use(express.urlencoded({ extended: true }));
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
app.use(express.static(path.join(__dirname, '../public')));
|
app.use(express.static(path.join(__dirname, '../public')));
|
||||||
|
|
||||||
// global middleware to define required local variables
|
|
||||||
app.use('/', function (req, res, next) {
|
|
||||||
res.locals.startPage = app.locals.config.startPage;
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
app.use('/', routes);
|
app.use('/', routes);
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
|
|
|
@ -4,8 +4,9 @@ const router = express.Router();
|
||||||
|
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
router.get('/', verifyToken, async (req, res) => {
|
router.get('/', verifyToken, async (req, res) => {
|
||||||
if (res.locals.startPage) {
|
const config = req.app.locals.config;
|
||||||
return res.redirect(res.locals.startPage);
|
if (config.startPage) {
|
||||||
|
return res.redirect(config.startPage);
|
||||||
}
|
}
|
||||||
res.render('pages/index', { isAuthorized: res.locals.isAuthorized });
|
res.render('pages/index', { isAuthorized: res.locals.isAuthorized });
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue