akf-forum/routes/admin.js

15 lines
553 B
JavaScript
Raw Normal View History

2022-10-09 22:57:46 +03:00
const { Router } = require("express");
const fs = require("fs");
const { BanModel, UserModel } = require("../models");
2022-03-21 23:53:22 +03:00
const app = Router();
2022-10-09 22:57:46 +03:00
app.use(async (req, res, next) => {
if (!req.user?.admin) return res.error(403, "You are not admin");
next();
});
2022-04-06 21:14:46 +03:00
app.get("/", async (req, res) => {
2022-10-09 22:57:46 +03:00
res.reply("admin", { bans: await BanModel.find({}), admins: await UserModel.find({ admin: true }) });
});
app.get("/config", async (req, res) => {
res.reply("config", { config: fs.readFileSync("./config.json", "utf8") });
2022-04-03 21:01:55 +03:00
});
2022-08-29 16:16:44 +03:00
module.exports = app;