1
0
mirror of https://dev.s-ul.net/Galexion/MaiMaiDXNet.git synced 2024-11-30 20:54:31 +01:00
MaiMaiDXNet/routes/index.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-02-17 00:50:32 +01:00
var express = require('express');
var router = express.Router();
var fetch = require('cross-fetch');
2023-05-07 07:20:04 +02:00
var config = require('../config.json');
var { getUserCount, getUserData } = require("../dbhandler.js");
2023-02-17 00:50:32 +01:00
/* GET home page. */
var title = 'MaiDXNet';
router.get('/', async function (req, res, next) {
var usersRegistered = await getUserCount().then(
(userCount) => {
2023-02-17 00:50:32 +01:00
var params = {
totalUsers: userCount // ToDo: Change this to use the internal dbhandler api
};
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;