mirror of
https://dev.s-ul.net/Galexion/MaiMaiDXNet.git
synced 2024-11-30 20:44:28 +01:00
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
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) {
|
|
var usersRegistered = await getUserCount().then(
|
|
(userCount) => {
|
|
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; |