aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/index.js23
1 files changed, 14 insertions, 9 deletions
diff --git a/routes/index.js b/routes/index.js
index 570fe5f..68f29b7 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -2,19 +2,24 @@
const express = require('express')
const router = express.Router()
-const data = require('../lib/getUserIndex')
+const getMeetingpointData = require('../lib/getMeetingpointData')
/* GET home page. */
router.get('/', function (req, res, next) {
- let flags = []
- if (req.query.nfd != null) {
- flags.push('NO_FEATURE_DETECT')
- }
+ 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', { flagsStr, usersStr, validWeekNumbersStr })
+ 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', { flagsStr, usersStr, validWeekNumbersStr })
+ }).catch(function () {
+ console.error('Unable to get user info, emergency redirect!')
+ res.redirect('http://www.meetingpointmco.nl/Roosters-AL/doc/')
+ })
})
module.exports = router