mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-08 06:55:26 +02:00
Move startPage configuration to env
This commit is contained in:
parent
ea690d4eb0
commit
1b32747e20
4 changed files with 10 additions and 5 deletions
|
@ -8,6 +8,7 @@
|
||||||
{"title": "Support Project", "uri": "/support"}
|
{"title": "Support Project", "uri": "/support"}
|
||||||
],
|
],
|
||||||
"landingFrameSrc": "https://codex.so/editor?frame=1",
|
"landingFrameSrc": "https://codex.so/editor?frame=1",
|
||||||
|
"startPage": "codex",
|
||||||
"misprintsChatId": "12344564",
|
"misprintsChatId": "12344564",
|
||||||
"yandexMetrikaId": ""
|
"yandexMetrikaId": ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,5 @@
|
||||||
"port": 3000,
|
"port": 3000,
|
||||||
"database": ".db",
|
"database": ".db",
|
||||||
"uploads": "public/uploads",
|
"uploads": "public/uploads",
|
||||||
"secret": "iamasecretstring",
|
"secret": "iamasecretstring"
|
||||||
"startPage": "codex"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ 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) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const verifyToken = require('./middlewares/token');
|
const verifyToken = require('./middlewares/token');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const config = require('../../config/index');
|
|
||||||
|
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
router.get('/', verifyToken, async (req, res) => {
|
router.get('/', verifyToken, async (req, res) => {
|
||||||
if (config.startPage) {
|
console.log(res.locals);
|
||||||
return res.redirect(config.startPage);
|
if (res.locals.startPage) {
|
||||||
|
return res.redirect(res.locals.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