aboutsummaryrefslogtreecommitdiff
path: root/routes/index.js
blob: 37180159b3e6209bd85b98072442e59f162b31b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict'

const express = require('express')
const router = express.Router()
const getUserIndex = require('../lib/getUserIndex')

/* GET home page. */
router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], function (req, res, next) {
  getUserIndex().then(users => {
    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')
    }

    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