2023-02-19 03:32:25 +01:00
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router();
|
2023-03-17 13:42:16 +01:00
|
|
|
|
2023-03-05 15:26:56 +01:00
|
|
|
const minify = require('express-minify');
|
2023-02-19 03:32:25 +01:00
|
|
|
|
2023-03-17 13:42:16 +01:00
|
|
|
// custom
|
2023-03-05 14:56:16 +01:00
|
|
|
router.use(require('./template'));
|
2023-02-26 15:18:26 +01:00
|
|
|
router.use(require('./cookie'));
|
2023-02-25 07:33:13 +01:00
|
|
|
router.use(require('./session'));
|
|
|
|
router.use(require('./session_back'));
|
2023-02-19 03:32:25 +01:00
|
|
|
|
2023-03-17 13:42:16 +01:00
|
|
|
// libs
|
2023-03-05 15:26:56 +01:00
|
|
|
router.use(minify({
|
|
|
|
cache: process.env.APP_DEBUG == true,
|
|
|
|
uglifyJS: null,
|
|
|
|
errorHandler: console.error,
|
|
|
|
css_match: /.css^/,
|
|
|
|
js_match: /.js^/
|
|
|
|
}));
|
|
|
|
|
2023-03-17 13:42:16 +01:00
|
|
|
// TODO: Maybe move all regexes into one file? Idk
|
2023-03-18 08:16:00 +01:00
|
|
|
const legacy_re = /(Firefox\/[0-5]\d{0,1}|Mozilla\/[0-4]|MSIE \d{1,2}\.\d{1,2}|Windows (NT|9\d)|Linux i686|(198\d|199\d|200\d|201[0-6])|Dillo|Naenara|Navscape|Netscape|QtWeb|Prism|Tencent|i(Phone|Pad|Pod)( OS [1-5]|))/g;
|
2023-03-17 13:42:16 +01:00
|
|
|
|
|
|
|
router.use((req, res, next) => {
|
|
|
|
req.legacymode = req.headers['user-agent'].match(legacy_re);
|
2023-03-18 08:16:00 +01:00
|
|
|
// res.send(req.headers['user-agent']);return;
|
2023-03-17 13:42:16 +01:00
|
|
|
next();
|
|
|
|
});
|
|
|
|
|
2023-02-19 03:32:25 +01:00
|
|
|
module.exports = router;
|