akf-forum/routes/.js

26 lines
576 B
JavaScript
Raw Normal View History

2022-03-21 23:53:22 +03:00
const { User } = require("../classes");
2022-03-13 16:16:46 +03:00
const { get } = require("quick.db")
2022-03-21 23:53:22 +03:00
const { Router } = require("express");
const app = Router();
app.get("/", (req, res) => {
2022-03-13 16:16:46 +03:00
if (!req.session.loggedin) return res.redirect('/login');
const mem = process.memoryUsage().heapUsed / Math.pow(2, 20);
2022-03-21 23:53:22 +03:00
2022-03-13 16:16:46 +03:00
const users = get("users").length;
2022-03-21 23:53:22 +03:00
2022-03-13 16:16:46 +03:00
const threads = get("threads").length;
2022-03-21 23:53:22 +03:00
2022-03-13 16:16:46 +03:00
const messages = get("messages").length;
2022-03-21 23:53:22 +03:00
2022-03-13 16:16:46 +03:00
const user = new User().getId(req.session.userid)
2022-03-21 23:53:22 +03:00
2022-03-13 16:16:46 +03:00
res.render("index", { mem, user, users, threads, messages })
2022-03-21 23:53:22 +03:00
})
module.exports = app;