summary refs log tree commit diff
path: root/src/routes/guilds
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-04-06 18:02:10 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-04-06 18:02:10 +0200
commit70892870161edad2a44ae36bdf9092961ef830bb (patch)
tree4763c7099023784ac7c020ed1dde29223728fd14 /src/routes/guilds
parent:bug: fix body parser empty error object (diff)
downloadserver-70892870161edad2a44ae36bdf9092961ef830bb.tar.xz
:art: Convert id bigint to string
Diffstat (limited to 'src/routes/guilds')
-rw-r--r--src/routes/guilds/#id/bans.ts14
-rw-r--r--src/routes/guilds/#id/channels.ts4
-rw-r--r--src/routes/guilds/#id/index.ts6
-rw-r--r--src/routes/guilds/#id/members.ts10
4 files changed, 17 insertions, 17 deletions
diff --git a/src/routes/guilds/#id/bans.ts b/src/routes/guilds/#id/bans.ts
index ba062a44..e66ae3d4 100644
--- a/src/routes/guilds/#id/bans.ts
+++ b/src/routes/guilds/#id/bans.ts
@@ -11,7 +11,7 @@ import { getPublicUser } from "../../../util/User";
 const router: Router = Router();
 
 router.get("/", async (req: Request, res: Response) => {
-	const guild_id = BigInt(req.params.id);
+	const guild_id = req.params.id;
 
 	const guild = await GuildModel.findOne({ id: guild_id }).exec();
 	if (!guild) throw new HTTPError("Guild not found", 404);
@@ -21,8 +21,8 @@ router.get("/", async (req: Request, res: Response) => {
 });
 
 router.get("/:user", async (req: Request, res: Response) => {
-	const guild_id = BigInt(req.params.id);
-	const user_id = BigInt(req.params.ban);
+	const guild_id = req.params.id;
+	const user_id = req.params.ban;
 
 	var ban = await BanModel.findOne({ guild_id: guild_id, user_id: user_id }).exec();
 	if (!ban) throw new HTTPError("Ban not found", 404);
@@ -30,8 +30,8 @@ router.get("/:user", async (req: Request, res: Response) => {
 });
 
 router.post("/:user_id", check(BanCreateSchema), async (req: Request, res: Response) => {
-	const guild_id = BigInt(req.params.id);
-	const banned_user_id = BigInt(req.params.user_id);
+	const guild_id = req.params.id;
+	const banned_user_id = req.params.user_id;
 
 	const banned_user = await getPublicUser(banned_user_id);
 	const perms = await getPermission(req.user_id, guild_id);
@@ -61,8 +61,8 @@ router.post("/:user_id", check(BanCreateSchema), async (req: Request, res: Respo
 });
 
 router.delete("/:user_id", async (req: Request, res: Response) => {
-	var guild_id = BigInt(req.params.id);
-	var banned_user_id = BigInt(req.params.user_id);
+	var guild_id = req.params.id;
+	var banned_user_id = req.params.user_id;
 
 	const banned_user = await getPublicUser(banned_user_id);
 	const guild = await GuildModel.findOne({ id: guild_id }, { id: true }).exec();
diff --git a/src/routes/guilds/#id/channels.ts b/src/routes/guilds/#id/channels.ts
index df41ec41..cd03fdbb 100644
--- a/src/routes/guilds/#id/channels.ts
+++ b/src/routes/guilds/#id/channels.ts
@@ -6,14 +6,14 @@ import { check } from "../../../util/instanceOf";
 const router = Router();
 
 router.get("/", async (req, res) => {
-	const guild_id = BigInt(req.params.id);
+	const guild_id = (req.params.id);
 	const channels = await ChannelModel.find({ guild_id }).lean().exec();
 
 	res.json(channels);
 });
 
 router.post("/", check(ChannelModifySchema), async (req, res) => {
-	const guild_id = BigInt(req.params.id);
+	const guild_id = (req.params.id);
 	const body = req.body as ChannelModifySchema;
 	if (!body.permission_overwrites) body.permission_overwrites = [];
 	if (!body.topic) body.topic = "";
diff --git a/src/routes/guilds/#id/index.ts b/src/routes/guilds/#id/index.ts
index 9b5ce313..385904f6 100644
--- a/src/routes/guilds/#id/index.ts
+++ b/src/routes/guilds/#id/index.ts
@@ -19,7 +19,7 @@ import { check } from "../../../util/instanceOf";
 const router = Router();
 
 router.get("/", async (req: Request, res: Response) => {
-	const guild_id = BigInt(req.params.id);
+	const guild_id = req.params.id;
 
 	const guild = await GuildModel.findOne({ id: guild_id }).exec();
 	if (!guild) throw new HTTPError("Guild does not exist", 404);
@@ -32,7 +32,7 @@ router.get("/", async (req: Request, res: Response) => {
 
 router.patch("/", check(GuildUpdateSchema), async (req: Request, res: Response) => {
 	const body = req.body as GuildUpdateSchema;
-	const guild_id = BigInt(req.params.id);
+	const guild_id = req.params.id;
 
 	const guild = await GuildModel.findOne({ id: guild_id }).exec();
 	if (!guild) throw new HTTPError("This guild does not exist", 404);
@@ -45,7 +45,7 @@ router.patch("/", check(GuildUpdateSchema), async (req: Request, res: Response)
 });
 
 router.delete("/", async (req: Request, res: Response) => {
-	var guild_id = BigInt(req.params.id);
+	var guild_id = req.params.id;
 
 	const guild = await GuildModel.findOne({ id: guild_id }, "owner_id").exec();
 	if (!guild) throw new HTTPError("This guild does not exist", 404);
diff --git a/src/routes/guilds/#id/members.ts b/src/routes/guilds/#id/members.ts
index 25889e2e..f95bd313 100644
--- a/src/routes/guilds/#id/members.ts
+++ b/src/routes/guilds/#id/members.ts
@@ -10,12 +10,12 @@ const router = Router();
 // TODO: not allowed for user -> only allowed for bots with privileged intents
 // TODO: send over websocket
 router.get("/", async (req: Request, res: Response) => {
-	const guild_id = BigInt(req.params.id);
+	const guild_id = req.params.id;
 	const guild = await GuildModel.findOne({ id: guild_id }).exec();
 	if (!guild) throw new HTTPError("Guild not found", 404);
 
 	try {
-		instanceOf({ $limit: new Length(Number, 1, 1000), $after: BigInt }, req.query, {
+		instanceOf({ $limit: new Length(Number, 1, 1000), $after: String }, req.query, {
 			path: "query",
 			req,
 			ref: { obj: null, key: "" },
@@ -26,7 +26,7 @@ router.get("/", async (req: Request, res: Response) => {
 
 	// @ts-ignore
 	if (!req.query.limit) req.query.limit = 1;
-	const { limit, after } = (<unknown>req.query) as { limit: number; after: bigint };
+	const { limit, after } = (<unknown>req.query) as { limit: number; after: string };
 	const query = after ? { id: { $gt: after } } : {};
 
 	var members = await MemberModel.find({ guild_id, ...query }, PublicMemberProjection)
@@ -39,8 +39,8 @@ router.get("/", async (req: Request, res: Response) => {
 });
 
 router.get("/:member", async (req: Request, res: Response) => {
-	const guild_id = BigInt(req.params.id);
-	const user_id = BigInt(req.params.member);
+	const guild_id = req.params.id;
+	const user_id = req.params.member;
 
 	const member = await MemberModel.findOne({ id: user_id, guild_id }).populate({ path: "user", select: PublicUserProjection }).exec();
 	if (!member) throw new HTTPError("Member not found", 404);