1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-07 06:25:21 +02:00

Changed naming in config, from faviconURL to favicon, changed using app.locals variables

This commit is contained in:
slaveeks 2022-07-06 12:25:09 +03:00
parent 3cab15e514
commit 8e2c4b317e
9 changed files with 21 additions and 25 deletions

View file

@ -87,14 +87,14 @@ yarn test
You can configure application using configs in <code>/config</code> directory.
| Property | Role |
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| <code>port</code> | to set port of application |
| <code>database</code> | to name directory with data |
| <code>rcFile</code> | to set destination of codexdocsrc config file |
| <code>uploads</code> | to set destination of directory to save uploads |
| <code>secret</code> | to set secret |
| <code>faviconURL</code> | to set url to get favicon. Server uploads file by url and saves it to temporary directory. And you can get favicon by /favicon route of application |
| Property | Role |
|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <code>port</code> | to set port of application |
| <code>database</code> | to name directory with data |
| <code>rcFile</code> | to set destination of codexdocsrc config file |
| <code>uploads</code> | to set destination of directory to save uploads |
| <code>secret</code> | to set secret |
| <code>favicon</code> | to set url or path to get favicon. Server uploads file by url and saves it to temporary directory. And you can get favicon by /favicon static route of application |
You can configure application using configs in <code>/config</code> directory.

View file

@ -4,5 +4,5 @@
"rcFile": "./.codexdocsrc",
"uploads": "public/uploads",
"secret": "iamasecretstring",
"faviconURL": ""
"favicon": ""
}

View file

@ -4,5 +4,5 @@
"rcFile": "./.codexdocsrc",
"uploads": "/uploads",
"secret": "iamasecretstring",
"faviconURL": ""
"favicon": ""
}

View file

@ -4,5 +4,5 @@
"rcFile": "./src/test/.codexdocsrc",
"uploads": "public/uploads_test",
"secret": "iamasecretstring",
"faviconURL": ""
"favicon": ""
}

View file

@ -16,7 +16,7 @@ const app = express();
const localConfig = rcParser.getConfiguration();
// Get url to upload favicon from config
const faviconURL: string = appConfig.get('faviconURL');
const faviconURL: string = appConfig.get('favicon');
app.locals.config = localConfig;
// view engine setup

View file

@ -3,7 +3,6 @@ import Aliases from '../controllers/aliases';
import Pages from '../controllers/pages';
import Alias from '../models/alias';
import verifyToken from './middlewares/token';
import app from '../app';
const router = express.Router();
@ -37,7 +36,7 @@ router.get('*', verifyToken, async (req: Request, res: Response) => {
page,
pageParent,
config: req.app.locals.config,
favicon: app.locals.favicon,
favicon: req.app.locals.favicon,
});
}
}

View file

@ -2,7 +2,6 @@ import express, { Request, Response } from 'express';
import jwt from 'jsonwebtoken';
import config from 'config';
import csrf from 'csurf';
import app from '../app';
const router = express.Router();
const csrfProtection = csrf({ cookie: true });
@ -15,7 +14,7 @@ router.get('/auth', csrfProtection, function (req: Request, res: Response) {
res.render('auth', {
title: 'Login page',
csrfToken: req.csrfToken(),
favicon: app.locals.favicon,
favicon: req.app.locals.favicon,
});
});
@ -29,7 +28,7 @@ router.post('/auth', parseForm, csrfProtection, async (req: Request, res: Respon
title: 'Login page',
header: 'Password not set',
csrfToken: req.csrfToken(),
favicon: app.locals.favicon,
favicon: req.app.locals.favicon,
});
return;
@ -40,7 +39,7 @@ router.post('/auth', parseForm, csrfProtection, async (req: Request, res: Respon
title: 'Login page',
header: 'Wrong password',
csrfToken: req.csrfToken(),
favicon: app.locals.favicon,
favicon: req.app.locals.favicon,
});
return;
@ -63,7 +62,7 @@ router.post('/auth', parseForm, csrfProtection, async (req: Request, res: Respon
title: 'Login page',
header: 'Password not set',
csrfToken: req.csrfToken(),
favicon: app.locals.favicon
favicon: req.app.locals.favicon
});
return;

View file

@ -1,6 +1,5 @@
import express, { Request, Response } from 'express';
import verifyToken from './middlewares/token';
import app from '../app';
const router = express.Router();
@ -12,7 +11,7 @@ router.get('/', verifyToken, async (req: Request, res: Response) => {
return res.redirect(config.startPage);
}
res.render('pages/index', { isAuthorized: res.locals.isAuthorized,
favicon: app.locals.favicon });
favicon: req.app.locals.favicon });
});
export default router;

View file

@ -3,7 +3,6 @@ import Pages from '../controllers/pages';
import PagesOrder from '../controllers/pagesOrder';
import verifyToken from './middlewares/token';
import allowEdit from './middlewares/locals';
import app from '../app';
const router = express.Router();
@ -17,7 +16,7 @@ router.get('/page/new', verifyToken, allowEdit, async (req: Request, res: Respon
res.render('pages/form', {
pagesAvailable,
page: null,
favicon: app.locals.favicon,
favicon: req.app.locals.favicon,
});
} catch (error) {
res.status(404);
@ -45,7 +44,7 @@ router.get('/page/edit/:id', verifyToken, allowEdit, async (req: Request, res: R
page,
parentsChildrenOrdered,
pagesAvailable,
favicon: app.locals.favicon,
favicon: req.app.locals.favicon,
});
} catch (error) {
res.status(404);
@ -68,7 +67,7 @@ router.get('/page/:id', verifyToken, async (req: Request, res: Response, next: N
page,
pageParent,
config: req.app.locals.config,
favicon: app.locals.favicon,
favicon: req.app.locals.favicon,
});
} catch (error) {
res.status(404);