diff options
author | Noah Loomans <noahloomans@gmail.com> | 2017-05-26 18:35:51 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2017-05-26 18:35:51 +0200 |
commit | a6a4ddc10ba1a458b94b13c59a4081e9ce1e5b33 (patch) | |
tree | 7b72b1131f74103d248d88778b2d05e2a93e106d /routes | |
parent | df9e9c861631274e3b6ba936cd7dae249e0003ea (diff) |
Add emergency redirect
Diffstat (limited to 'routes')
-rw-r--r-- | routes/index.js | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/routes/index.js b/routes/index.js index a65ac69..0fc0d30 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,24 +2,33 @@ const express = require('express') const router = express.Router() -const users = require('../lib/getUserIndex') +const getUserIndex = require('../lib/getUserIndex') -/* GET home page. */ -router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], function (req, res, next) { - const isBeta = process.env.BETA === '1' +getUserIndex().then(users => { + /* GET home page. */ + router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], function (req, res, next) { + const isBeta = process.env.BETA === '1' - let flags = [] - if (isBeta) { - flags.push('BETA') - flags.push('NO_FEATURE_DETECT') - } else if (req.query.nfd != null) { - flags.push('NO_FEATURE_DETECT') - } + let flags = [] + if (isBeta) { + flags.push('BETA') + flags.push('NO_FEATURE_DETECT') + } else if (req.query.nfd != null) { + flags.push('NO_FEATURE_DETECT') + } - const flagsStr = `var FLAGS = ${JSON.stringify(flags)};` - const usersStr = `var USERS = ${JSON.stringify(users.users)};` + const flagsStr = `var FLAGS = ${JSON.stringify(flags)};` + const usersStr = `var USERS = ${JSON.stringify(users)};` - res.render('index', { flagsStr, usersStr, isBeta }) + res.render('index', { flagsStr, usersStr, isBeta }) + }) +}, error => { + console.error('Unable to get user info, emergency redirect!') + console.error('Error:', error) + + router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], function (req, res, next) { + res.redirect('http://www.meetingpointmco.nl/Roosters-AL/doc/') + }) }) module.exports = router |