From 457946531c57a546eeb3c42042ad192ac9826299 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Fri, 26 May 2017 20:08:45 +0200 Subject: Autoupdate user index cache --- routes/index.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'routes/index.js') 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/') }) }) -- cgit v1.1