Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
appujet committed Aug 31, 2023
1 parent afd6055 commit 74cccf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import express, { Express, Request, Response, NextFunction, Router } from 'express';
import express, { Express, Request, Response, NextFunction } from 'express';
import passport from "passport";
import Logger from '../structures/Logger';
import config from '../config';
Expand All @@ -21,7 +21,7 @@ export class DiscordDashboard {
this.app.use(express.urlencoded({ extended: true }));
this.app.use(this.errorHandler.bind(this));
this.app.use(cors({
origin: config.dashboard.host + ':' + config.dashboard.port,
origin: config.dashboard.website,
credentials: true
}));
this.app.use(session({
Expand Down
8 changes: 8 additions & 0 deletions src/api/routes/guilds/GuildRouter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Router, Request, Response } from "express";
import { IsAuth } from "../../middlewares/Middlewares";
import { getGuild, getGuildMembers } from "../../services/guilds/GuildServices";
import ServerData from "../../../database/server";


class GuildRouter {
Expand All @@ -12,6 +13,7 @@ class GuildRouter {
private initializeRoutes() {
this.router.get("/:id", IsAuth, this.getGuild);
this.router.get("/:id/members", IsAuth, this.getGuildsMembers);
this.router.post("/:id/prefix", IsAuth, this.updateGuildPrefix);
}
private async getGuild(req: Request, res: Response) {
const guild = await getGuild(req.params.id);
Expand All @@ -21,6 +23,12 @@ class GuildRouter {
const guild = await getGuildMembers(req.params.id);
return res.send(guild);
}

private async updateGuildPrefix(req: Request, res: Response) {
console.log(req.params.id, req.body.prefix);
await ServerData.setPrefix(req.params.id, req.body.prefix);
return res.sendStatus(200);
}
}

const guildRouter = new GuildRouter();
Expand Down

0 comments on commit 74cccf7

Please sign in to comment.