akf-forum/routes/.js

17 lines
643 B
JavaScript
Raw Normal View History

const { UserModel, ThreadModel, MessageModel, CategoryModel } = require("../models")
2022-03-21 23:53:22 +03:00
const { Router } = require("express");
const app = Router();
2022-04-06 21:14:46 +03:00
app.get("/", async (req, res) => {
2022-08-26 16:27:29 +03:00
const categories = await CategoryModel.count(),
users = await UserModel.count({ deleted: false }),
threads = await ThreadModel.count({ state: "OPEN" }),
messages = await MessageModel.count({ deleted: false }),
newestMember = await UserModel.findOne({ deleted: false }, "name").sort({ time: -1 });
2022-03-21 23:53:22 +03:00
res.reply("index", { categories, users, threads, messages, newestMember: newestMember.name });
2022-03-21 23:53:22 +03:00
2023-05-25 16:15:50 +03:00
});
2022-03-21 23:53:22 +03:00
module.exports = app;