mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-10 19:17:03 +00:00
flags related rights and stats api
This commit is contained in:
committed by
Madeline
parent
697cfb1f58
commit
3844d8a40b
@@ -0,0 +1,22 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { Config, getRights, Guild, Member, Message, User } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
if (!Config.get().security.statsWorldReadable) {
|
||||
const rights = await getRights(req.user_id);
|
||||
rights.hasThrow("VIEW_SERVER_STATS");
|
||||
}
|
||||
|
||||
res.json({
|
||||
counts: {
|
||||
user: await User.count(),
|
||||
guild: await Guild.count(),
|
||||
message: await Message.count(),
|
||||
members: await Member.count(),
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user