blob: e0b4d27f68f2c71e6fde6c58ca007fef231f5abb (
plain)
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
|
'use strict'
const express = require('express')
const router = express.Router()
const getMeetingpointData = require('../lib/getMeetingpointData')
/* GET home page. */
router.get('/', function (req, res, next) {
const baseMeetingpointUrl = process.env.SCHOOL_LEVEL === 'mavo'
? 'http://www.meetingpointmco.nl/Roosters-AL/TOSweb'
: 'http://www.meetingpointmco.nl/Roosters-AL/doc';
const school = process.env.SCHOOL === 'kiemm' ? 'kiemm' : 'metis';
getMeetingpointData().then(data => {
let flags = []
if (req.query.nfd != null) {
flags.push('NO_FEATURE_DETECT')
}
const flagsStr = `var FLAGS = ${JSON.stringify(flags)};`
const usersStr = `var USERS = ${JSON.stringify(data.users)};`
const validWeekNumbersStr = `var VALID_WEEK_NUMBERS = ${JSON.stringify(data.validWeekNumbers)}`
res.render('index', {
school,
schoolLevel: process.env.SCHOOL_LEVEL === 'mavo' ? 'mavo' : 'havo-vwo',
baseMeetingpointUrl,
flagsStr,
usersStr,
validWeekNumbersStr
})
}).catch(function () {
console.error('Unable to get user info, emergency redirect!')
res.render('redirect', {
school,
baseMeetingpointUrl,
})
})
})
module.exports = router
|