From 600128bda0390f2051ad20ee42930f036c79323c Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Tue, 5 Sep 2017 20:28:32 +0200 Subject: Clear cache automaticly --- routes/index.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'routes') 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 -- cgit v1.1