aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/index.js37
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