diff options
author | Puyodead1 <puyodead@proton.me> | 2023-03-24 21:53:59 -0400 |
---|---|---|
committer | Puyodead1 <puyodead@proton.me> | 2023-04-13 15:32:04 -0400 |
commit | 3fa2a954297df36d4c33186559c681d4967970b6 (patch) | |
tree | cd89fe6676ba4c009396f71a84ea9aadd013b70a /src/api/routes/policies/stats.ts | |
parent | oapi: oauth2 (diff) | |
download | server-3fa2a954297df36d4c33186559c681d4967970b6.tar.xz |
oapi: policies
Diffstat (limited to 'src/api/routes/policies/stats.ts')
-rw-r--r-- | src/api/routes/policies/stats.ts | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/src/api/routes/policies/stats.ts b/src/api/routes/policies/stats.ts index 3939e1e8..b2cd3d5a 100644 --- a/src/api/routes/policies/stats.ts +++ b/src/api/routes/policies/stats.ts @@ -28,20 +28,33 @@ import { 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(), +router.get( + "/", + route({ + responses: { + 200: { + body: "InstanceStatsResponse", + }, + 403: { + body: "APIErrorResponse", + }, }, - }); -}); + }), + 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; |