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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 349 - (hide annotations)
Mon Jul 29 17:29:43 2024 UTC (8 months, 2 weeks ago) by rakin
File MIME type: application/typescript
File size: 809 byte(s)
feat(api): auth middleware
1 rakin 326 import Controller from "../Controller";
2 rakin 349 import RequireAuth from "../middleware/RequireAuth";
3     import Request from "../Request";
4 rakin 326
5     export default class ConfigController extends Controller {
6 rakin 349 globalMiddleware(): Function[] {
7     return [RequireAuth];
8     }
9    
10 rakin 326 public async index(request: Request) {
11 rakin 349 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 rakin 326 }
23    
24     public async update(request: Request) {
25    
26     }
27     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26