summary refs log tree commit diff
path: root/api/src/routes/guilds/#guild_id
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/guilds/#guild_id')
-rw-r--r--api/src/routes/guilds/#guild_id/bans.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/channels.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/index.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/members/#member_id/index.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/members/index.ts24
-rw-r--r--api/src/routes/guilds/#guild_id/roles.ts3
-rw-r--r--api/src/routes/guilds/#guild_id/vanity-url.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts2
-rw-r--r--api/src/routes/guilds/#guild_id/widget.ts5
9 files changed, 17 insertions, 27 deletions
diff --git a/api/src/routes/guilds/#guild_id/bans.ts b/api/src/routes/guilds/#guild_id/bans.ts
index c7fda9ad..e7d46898 100644
--- a/api/src/routes/guilds/#guild_id/bans.ts
+++ b/api/src/routes/guilds/#guild_id/bans.ts
@@ -1,7 +1,7 @@
 import { Request, Response, Router } from "express";
 import { emitEvent, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, Guild, Ban, User, Member } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { getIpAdress, check, route } from "@fosscord/api";
+import { getIpAdress, route } from "@fosscord/api";
 
 export interface BanCreateSchema {
 	delete_message_days?: string;
diff --git a/api/src/routes/guilds/#guild_id/channels.ts b/api/src/routes/guilds/#guild_id/channels.ts
index e21327d1..13c6b515 100644
--- a/api/src/routes/guilds/#guild_id/channels.ts
+++ b/api/src/routes/guilds/#guild_id/channels.ts
@@ -1,7 +1,7 @@
 import { Router, Response, Request } from "express";
 import { Channel, ChannelUpdateEvent, getPermission, emitEvent } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { check, route } from "@fosscord/api";
+import { route } from "@fosscord/api";
 import { ChannelModifySchema } from "../../channels/#channel_id";
 const router = Router();
 
diff --git a/api/src/routes/guilds/#guild_id/index.ts b/api/src/routes/guilds/#guild_id/index.ts
index 690d4103..a75d1138 100644
--- a/api/src/routes/guilds/#guild_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/index.ts
@@ -1,7 +1,7 @@
 import { Request, Response, Router } from "express";
 import { emitEvent, getPermission, Guild, GuildUpdateEvent, Member } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { check, route } from "@fosscord/api";
+import { route } from "@fosscord/api";
 import { handleFile } from "@fosscord/api";
 import "missing-native-js-functions";
 import { GuildCreateSchema } from "../index";
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
index 1708b7eb..ab489743 100644
--- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -1,7 +1,7 @@
 import { Request, Response, Router } from "express";
 import { Member, getPermission, Role, GuildMemberUpdateEvent, emitEvent } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { check, route } from "@fosscord/api";
+import { route } from "@fosscord/api";
 
 const router = Router();
 
diff --git a/api/src/routes/guilds/#guild_id/members/index.ts b/api/src/routes/guilds/#guild_id/members/index.ts
index 335f21c7..386276c8 100644
--- a/api/src/routes/guilds/#guild_id/members/index.ts
+++ b/api/src/routes/guilds/#guild_id/members/index.ts
@@ -1,7 +1,8 @@
 import { Request, Response, Router } from "express";
 import { Guild, Member, PublicMemberProjection } from "@fosscord/util";
-import { instanceOf, Length, route } from "@fosscord/api";
+import { route } from "@fosscord/api";
 import { MoreThan } from "typeorm";
+import { HTTPError } from "lambert-server";
 
 const router = Router();
 
@@ -11,26 +12,17 @@ const router = Router();
 
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const { guild_id } = req.params;
-	const guild = await Guild.findOneOrFail({ id: guild_id });
-	await Member.IsInGuildOrFail(req.user_id, guild_id);
-
-	try {
-		instanceOf({ $limit: new Length(Number, 1, 1000), $after: String }, req.query, {
-			path: "query",
-			req,
-			ref: { obj: null, key: "" }
-		});
-	} catch (error) {
-		return res.status(400).json({ code: 50035, message: "Invalid Query", success: false, errors: error });
-	}
-
-	const { limit, after } = (<unknown>req.query) as { limit?: number; after?: string };
+	const limit = Number(req.query.limit) || 1;
+	if (limit > 1000 || limit < 1) throw new HTTPError("Limit must be between 1 and 1000");
+	const after = `${req.query.after}`;
 	const query = after ? { id: MoreThan(after) } : {};
 
+	await Member.IsInGuildOrFail(req.user_id, guild_id);
+
 	const members = await Member.find({
 		where: { guild_id, ...query },
 		select: PublicMemberProjection,
-		take: limit || 1,
+		take: limit,
 		order: { id: "ASC" }
 	});
 
diff --git a/api/src/routes/guilds/#guild_id/roles.ts b/api/src/routes/guilds/#guild_id/roles.ts
index 5c549262..bac63bd4 100644
--- a/api/src/routes/guilds/#guild_id/roles.ts
+++ b/api/src/routes/guilds/#guild_id/roles.ts
@@ -11,8 +11,7 @@ import {
 	DiscordApiErrors
 } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
-import { check, route } from "@fosscord/api";
-import { In } from "typeorm";
+import { route } from "@fosscord/api";
 
 const router: Router = Router();
 
diff --git a/api/src/routes/guilds/#guild_id/vanity-url.ts b/api/src/routes/guilds/#guild_id/vanity-url.ts
index 9c0989cc..801768fb 100644
--- a/api/src/routes/guilds/#guild_id/vanity-url.ts
+++ b/api/src/routes/guilds/#guild_id/vanity-url.ts
@@ -1,6 +1,6 @@
 import { Channel, ChannelType, getPermission, Guild, Invite, trimSpecial } from "@fosscord/util";
 import { Router, Request, Response } from "express";
-import { check, Length, route } from "@fosscord/api";
+import { route } from "@fosscord/api";
 
 const router = Router();
 
diff --git a/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts b/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts
index 3d76938b..f9fbea54 100644
--- a/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts
+++ b/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts
@@ -1,5 +1,5 @@
 import { Channel, ChannelType, DiscordApiErrors, emitEvent, getPermission, VoiceState, VoiceStateUpdateEvent } from "@fosscord/util";
-import { check, route } from "@fosscord/api";
+import { route } from "@fosscord/api";
 import { Request, Response, Router } from "express";
 
 const router = Router();
diff --git a/api/src/routes/guilds/#guild_id/widget.ts b/api/src/routes/guilds/#guild_id/widget.ts
index c8caae14..2640618d 100644
--- a/api/src/routes/guilds/#guild_id/widget.ts
+++ b/api/src/routes/guilds/#guild_id/widget.ts
@@ -1,7 +1,6 @@
 import { Request, Response, Router } from "express";
-import { getPermission, Guild } from "@fosscord/util";
-import { HTTPError } from "lambert-server";
-import { check, route } from "@fosscord/api";
+import { Guild } from "@fosscord/util";
+import { route } from "@fosscord/api";
 
 export interface WidgetModifySchema {
 	enabled: boolean; // whether the widget is enabled