var express = require('express'); var router = express.Router(); var fetch = require('cross-fetch'); var config = require('../config.json'); var { getUserCount, getUserData } = require("../dbhandler.js"); /* GET home page. */ var title = 'MaiDXNet'; router.get('/', async function (req, res, next) { await getUserCount().then( (userCount) => { var params = { totalUsers: userCount, // ToDo: Change this to use the internal dbhandler api serverType: config.serverType }; console.log(`Recived User Count:`+userCount); res.render('index', { title: title, params: params }); }, (reason) => { res.render('error', { title: title, error: reason }); console.error(reason); // Error! }, ); }); router.get('/user', async function (req, res, next) { try { const cookies = req.cookies console.log(cookies) if (cookies.aime_card_id === undefined) { return res.redirect("/") } res.render('user', { title: title, userdata: await getUserData(req) }); } catch (err) { res.render('error', { error: err }); } }); module.exports = router;