-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (38 loc) · 1.75 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
const { setup } = require('hmpo-app');
const { options} = require('./config');
const birthRoute = require('./routes/birth');
const deathRoute = require('./routes/death');
const marriageRoute = require('./routes/marriage');
const partnershipRoute = require('./routes/partnership');
const metricsRoute = require('./routes/metrics');
const userActivityRoute = require('./routes/user-activity');
const organisationsRoute = require('./routes/organisation');
const accessTest = require('./routes/access-test');
const accessibilityStatement = require('./routes/accessibility-statement');
const syops = require('./routes/syops');
const { syopsAcceptanceCheck } = require("./middleware/syopsAcceptanceCheck");
const { router } = setup(options);
let originalRequestUrl = '/';
router.use((req, res, next) => {
if(!req.url.toLowerCase().includes('syops') && !req.url.toLowerCase().includes('metrics') && !req.url.toLowerCase().includes('access-test') && !req.url.toLowerCase().includes('public') && !req.url.toLowerCase().includes('assets')) {
originalRequestUrl = req.url;
}
req.originalRequestUrl = originalRequestUrl
next();
});
// routes for static assets
router.use('/access-test', accessTest);
router.use('/accessibility-statement', accessibilityStatement);
router.use('/syops', syops);
router.use('/metrics', metricsRoute);
// middleware to check syops acceptance
router.use((req, res, next) => syopsAcceptanceCheck(req, res, next));
// routes
router.use('/birth', birthRoute);
router.use('/death', deathRoute);
router.use('/marriage', marriageRoute);
router.use('/partnership', partnershipRoute);
router.use('/audit/user-activity', userActivityRoute);
router.use('/admin/organisations', organisationsRoute);
router.use('/', (req, res) => res.redirect('/birth'));