diff options
Diffstat (limited to 'routes/index.js')
-rw-r--r-- | routes/index.js | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/routes/index.js b/routes/index.js index 1ab2ba3..3718015 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,18 +2,29 @@ const express = require('express') const router = express.Router() -const users = require('../lib/getUserIndex') +const getUserIndex = require('../lib/getUserIndex') /* GET home page. */ -router.get('/', function (req, res, next) { - let flags = [] - if (req.query.nfd != null) { - flags.push('NO_FEATURE_DETECT') - } +router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], function (req, res, next) { + getUserIndex().then(users => { + const isBeta = process.env.BETA === '1' - const flagsStr = `var FLAGS = ${JSON.stringify(flags)};` - const usersStr = `var USERS = ${JSON.stringify(users.users)};` - res.render('index', { flagsStr, usersStr }) + 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)};` + + res.render('index', { flagsStr, usersStr, isBeta }) + }).catch(function () { + console.error('Unable to get user info, emergency redirect!') + res.redirect('http://www.meetingpointmco.nl/Roosters-AL/doc/') + }) }) module.exports = router |