diff options
author | Noah Loomans <noahloomans@gmail.com> | 2017-05-26 20:08:45 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2017-05-26 20:08:45 +0200 |
commit | 457946531c57a546eeb3c42042ad192ac9826299 (patch) | |
tree | dae865d9b416513d4e4405186b483cb9446c6e39 /routes | |
parent | 065c4feb424046599f22960e0fa19898ad9cd6f7 (diff) |
Autoupdate user index cache
Diffstat (limited to 'routes')
-rw-r--r-- | routes/index.js | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/routes/index.js b/routes/index.js index 0fc0d30..3718015 100644 --- a/routes/index.js +++ b/routes/index.js @@ -4,9 +4,9 @@ const express = require('express') const router = express.Router() const getUserIndex = require('../lib/getUserIndex') -getUserIndex().then(users => { - /* GET home page. */ - router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], function (req, res, next) { +/* GET home page. */ +router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], function (req, res, next) { + getUserIndex().then(users => { const isBeta = process.env.BETA === '1' let flags = [] @@ -21,12 +21,8 @@ getUserIndex().then(users => { const usersStr = `var USERS = ${JSON.stringify(users)};` 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) { + }).catch(function () { + console.error('Unable to get user info, emergency redirect!') res.redirect('http://www.meetingpointmco.nl/Roosters-AL/doc/') }) }) |