From 5c265c04ad513d845a41c7866c3ed231c8d5e68e Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Sat, 7 Jul 2018 17:34:02 +0200 Subject: server: Use database for users --- src/server/routes/index.js | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'src/server/routes/index.js') diff --git a/src/server/routes/index.js b/src/server/routes/index.js index d647210..b0e86ee 100644 --- a/src/server/routes/index.js +++ b/src/server/routes/index.js @@ -21,31 +21,13 @@ const express = require('express'); const router = express.Router(); -const getScheduleData = require('../lib/schools/hetmml/getScheduleData'); +const { getUsers } = require('../../shared/lib/db'); /* GET home page. */ -router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], (req, res) => { - getScheduleData().then(({ users, dailyScheduleWeeks, basisScheduleWeeks }) => { - const isBeta = process.env.BETA === '1'; - - const 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)};`; - const dailyScheduleWeeksStr = `var DAGROOSTER_WEEKS = ${JSON.stringify(dailyScheduleWeeks)}`; - const basisScheduleWeeksStr = `var BASISROOSTER_WEEKS = ${JSON.stringify(basisScheduleWeeks)}`; - +router.get(['/', '/student/*', '/teacher/*', '/room/*', '/class/*'], (req, res) => { + getUsers().then((users) => { res.render('index', { - flagsStr, - usersStr, - dailyScheduleWeeksStr, - basisScheduleWeeksStr, + usersStr: JSON.stringify(users), }); }); // .catch(() => { -- cgit v1.1