diff options
author | Noah Loomans <noahloomans@gmail.com> | 2017-09-05 20:28:32 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2017-09-05 20:28:32 +0200 |
commit | 600128bda0390f2051ad20ee42930f036c79323c (patch) | |
tree | d8af17fd1f30dc4b11f44763c3addba104636f40 /routes | |
parent | e3947f0d11864f40a2c0a202af99e0b14ff14dcf (diff) |
Clear cache automaticly
Diffstat (limited to 'routes')
-rw-r--r-- | routes/index.js | 23 |
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 |