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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 348 by rakin, Mon Jul 29 17:29:33 2024 UTC revision 349 by rakin, Mon Jul 29 17:29:43 2024 UTC
# Line 1  Line 1 
 import { Request } from "express";  
1  import Controller from "../Controller";  import Controller from "../Controller";
2    import RequireAuth from "../middleware/RequireAuth";
3    import Request from "../Request";
4    
5  export default class ConfigController extends Controller {  export default class ConfigController extends Controller {
6        globalMiddleware(): Function[] {
7            return [RequireAuth];
8        }
9    
10      public async index(request: Request) {      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) {      public async update(request: Request) {

Legend:
Removed from v.348  
changed lines
  Added in v.349

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26