/[sudobot]/trunk/src/api/controllers/ConfigController.ts
ViewVC logotype

Contents of /trunk/src/api/controllers/ConfigController.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 349 - (show annotations)
Mon Jul 29 17:29:43 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 809 byte(s)
feat(api): auth middleware
1 import Controller from "../Controller";
2 import RequireAuth from "../middleware/RequireAuth";
3 import Request from "../Request";
4
5 export default class ConfigController extends Controller {
6 globalMiddleware(): Function[] {
7 return [RequireAuth];
8 }
9
10 public async index(request: Request) {
11 const { id } = request.params;
12
13 if (!request.user?.guilds.includes(id)) {
14 return this.response({ error: "You don't have permission to access configuration of this guild." }, 403);
15 }
16
17 if (id === "global" || !this.client.config.props[id]) {
18 return this.response({ error: "No configuration found for the given guild ID" }, 404);
19 }
20
21 return this.client.config.props[id];
22 }
23
24 public async update(request: Request) {
25
26 }
27 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26