diff --git a/src/api/routes/applications/#application_id/index.ts b/src/api/routes/applications/#application_id/index.ts
index bf29f404..22340e9e 100644
--- a/src/api/routes/applications/#application_id/index.ts
+++ b/src/api/routes/applications/#application_id/index.ts
@@ -83,7 +83,7 @@ router.patch(
if (body.guild_id) {
const guild = await Guild.findOneOrFail({
where: { id: body.guild_id },
- select: ["owner_id"],
+ select: { owner_id: true },
});
if (guild.owner_id != req.user_id) throw new HTTPError("You must be the owner of the guild to link it to an application", 400);
}
diff --git a/src/api/routes/applications/@me.ts b/src/api/routes/applications/@me.ts
index c1cf0db0..1c4a7530 100644
--- a/src/api/routes/applications/@me.ts
+++ b/src/api/routes/applications/@me.ts
@@ -79,7 +79,7 @@ router.patch(
if (body.guild_id) {
const guild = await Guild.findOneOrFail({
where: { id: body.guild_id },
- select: ["owner_id"],
+ select: { owner_id: true },
});
if (guild.owner_id != req.user_id) throw new HTTPError("You must be the owner of the guild to link it to an application", 400);
}
diff --git a/src/api/routes/auth/forgot.ts b/src/api/routes/auth/forgot.ts
index db16c3be..26e1b353 100644
--- a/src/api/routes/auth/forgot.ts
+++ b/src/api/routes/auth/forgot.ts
@@ -63,7 +63,7 @@ router.post(
const user = await User.findOne({
where: [{ phone: login }, { email: login }],
- select: ["username", "id", "email"],
+ select: { username: true, id: true, email: true },
}).catch(() => {});
if (user && user.email) {
diff --git a/src/api/routes/auth/login.ts b/src/api/routes/auth/login.ts
index 911ad4a9..8b2e039a 100644
--- a/src/api/routes/auth/login.ts
+++ b/src/api/routes/auth/login.ts
@@ -67,7 +67,7 @@ router.post(
const user = await User.findOneOrFail({
where: [{ phone: login }, { email: login }],
- select: ["data", "id", "disabled", "deleted", "totp_secret", "mfa_enabled", "webauthn_enabled", "security_keys", "verified"],
+ select: { data: true, id: true, disabled: true, deleted: true, totp_secret: true, mfa_enabled: true, webauthn_enabled: true, security_keys: true, verified: true },
relations: ["security_keys", "settings"],
}).catch(() => {
throw FieldErrors({
diff --git a/src/api/routes/auth/mfa/totp.ts b/src/api/routes/auth/mfa/totp.ts
index b9f2fa85..dd107698 100644
--- a/src/api/routes/auth/mfa/totp.ts
+++ b/src/api/routes/auth/mfa/totp.ts
@@ -45,7 +45,7 @@ router.post(
where: {
totp_last_ticket: ticket,
},
- select: ["id", "totp_secret"],
+ select: { id: true, totp_secret: true },
relations: ["settings"],
});
diff --git a/src/api/routes/auth/mfa/webauthn.ts b/src/api/routes/auth/mfa/webauthn.ts
index da476ab4..0bc91cfe 100644
--- a/src/api/routes/auth/mfa/webauthn.ts
+++ b/src/api/routes/auth/mfa/webauthn.ts
@@ -54,7 +54,7 @@ router.post(
where: {
totp_last_ticket: ticket,
},
- select: ["id"],
+ select: { id: true },
relations: ["settings"],
});
diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts
index f1487589..3e3f2924 100644
--- a/src/api/routes/auth/register.ts
+++ b/src/api/routes/auth/register.ts
@@ -111,7 +111,7 @@ router.post(
// TODO: check if fingerprint was eligible generated
const exists = await User.findOne({
where: { fingerprints: body.fingerprint },
- select: ["id"],
+ select: { id: true },
});
if (exists) {
diff --git a/src/api/routes/auth/verify/resend.ts b/src/api/routes/auth/verify/resend.ts
index ce6672a7..4c0339bf 100644
--- a/src/api/routes/auth/verify/resend.ts
+++ b/src/api/routes/auth/verify/resend.ts
@@ -39,7 +39,7 @@ router.post(
async (req: Request, res: Response) => {
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["username", "email", "verified"],
+ select: { username: true, email: true, verified: true },
});
if (!user.email) {
diff --git a/src/api/routes/auth/verify/view-backup-codes-challenge.ts b/src/api/routes/auth/verify/view-backup-codes-challenge.ts
index d3d40d3e..7bfd6696 100644
--- a/src/api/routes/auth/verify/view-backup-codes-challenge.ts
+++ b/src/api/routes/auth/verify/view-backup-codes-challenge.ts
@@ -37,7 +37,7 @@ router.post(
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["data"],
+ select: { data: true },
});
if (!(await bcrypt.compare(password, user.data.hash || ""))) {
diff --git a/src/api/routes/channels/#channel_id/invites.ts b/src/api/routes/channels/#channel_id/invites.ts
index 45b7d790..be97e445 100644
--- a/src/api/routes/channels/#channel_id/invites.ts
+++ b/src/api/routes/channels/#channel_id/invites.ts
@@ -46,7 +46,7 @@ router.post(
const { channel_id } = req.params;
const channel = await Channel.findOneOrFail({
where: { id: channel_id },
- select: ["id", "name", "type", "guild_id"],
+ select: { id: true, name: true, type: true, guild_id: true },
});
isTextChannel(channel.type);
diff --git a/src/api/routes/channels/#channel_id/messages/search.ts b/src/api/routes/channels/#channel_id/messages/search.ts
index bec9a44c..ed1dfc33 100644
--- a/src/api/routes/channels/#channel_id/messages/search.ts
+++ b/src/api/routes/channels/#channel_id/messages/search.ts
@@ -45,7 +45,7 @@ router.get(
const { channel_id } = req.params;
const channel = await Channel.findOneOrFail({
where: { guild_id: req.params.guild_id },
- select: ["id"],
+ select: { id: true },
});
const {
content,
diff --git a/src/api/routes/guilds/#guild_id/delete.ts b/src/api/routes/guilds/#guild_id/delete.ts
index 4edd2c39..6e541da1 100644
--- a/src/api/routes/guilds/#guild_id/delete.ts
+++ b/src/api/routes/guilds/#guild_id/delete.ts
@@ -43,7 +43,7 @@ router.post(
const guild = await Guild.findOneOrFail({
where: { id: guild_id },
- select: ["owner_id"],
+ select: { owner_id: true },
});
if (guild.owner_id !== req.user_id) throw new HTTPError("You are not the owner of this guild", 401);
diff --git a/src/api/routes/guilds/#guild_id/messages/search.ts b/src/api/routes/guilds/#guild_id/messages/search.ts
index be00d5de..426d0dcf 100644
--- a/src/api/routes/guilds/#guild_id/messages/search.ts
+++ b/src/api/routes/guilds/#guild_id/messages/search.ts
@@ -89,7 +89,7 @@ router.get(
// get all channel IDs that this user can access
const channels = await Channel.find({
where: { guild_id: req.params.guild_id },
- select: ["id"],
+ select: { id: true },
});
const ids = [];
diff --git a/src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts b/src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts
index ab61325e..e4dccb3e 100644
--- a/src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts
+++ b/src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts
@@ -27,7 +27,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
// TODO: Is this route really not paginated?
const members = await Member.find({
- select: ["id"],
+ select: { id: true },
where: {
roles: {
id: role_id,
diff --git a/src/api/routes/guilds/#guild_id/roles/member-counts.ts b/src/api/routes/guilds/#guild_id/roles/member-counts.ts
index d77149d5..0f3a12ce 100644
--- a/src/api/routes/guilds/#guild_id/roles/member-counts.ts
+++ b/src/api/routes/guilds/#guild_id/roles/member-counts.ts
@@ -26,7 +26,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
const { guild_id } = req.params;
await Member.IsInGuildOrFail(req.user_id, guild_id);
- const role_ids = await Role.find({ where: { guild_id }, select: ["id"] });
+ const role_ids = await Role.find({ where: { guild_id }, select: { id: true } });
const counts: { [id: string]: number } = {};
for (const { id } of role_ids) {
counts[id] = await Member.count({ where: { roles: { id }, guild_id } });
diff --git a/src/api/routes/oauth2/authorize.ts b/src/api/routes/oauth2/authorize.ts
index 4dea75c6..849e79b1 100644
--- a/src/api/routes/oauth2/authorize.ts
+++ b/src/api/routes/oauth2/authorize.ts
@@ -75,7 +75,7 @@ router.get(
id: req.user_id,
bot: false,
},
- select: ["id", "username", "avatar", "discriminator", "public_flags"],
+ select: { id: true, username: true, avatar: true, discriminator: true, public_flags: true },
});
const guilds = await Member.find({
@@ -83,10 +83,11 @@ router.get(
id: req.user_id,
},
relations: ["guild", "roles", "user"],
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- //@ts-ignore
- // prettier-ignore
- select: ["guild.id", "guild.name", "guild.icon", "guild.mfa_level", "guild.owner_id", "roles.id", "user.flags"],
+ select: {
+ guild: { id: true, name: true, icon: true, mfa_level: true, owner_id: true },
+ roles: { id: true },
+ user: { flags: true },
+ },
});
const guildsWithPermissions = guilds.map((x) => {
diff --git a/src/api/routes/safety-hub/@me/index.ts b/src/api/routes/safety-hub/@me/index.ts
index 7d0e7ff9..e5701292 100644
--- a/src/api/routes/safety-hub/@me/index.ts
+++ b/src/api/routes/safety-hub/@me/index.ts
@@ -38,7 +38,7 @@ router.get(
async (req: Request, res: Response) => {
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["data"],
+ select: { data: true },
});
res.send({
diff --git a/src/api/routes/safety-hub/suspended/@me.ts b/src/api/routes/safety-hub/suspended/@me.ts
index 7d0e7ff9..e5701292 100644
--- a/src/api/routes/safety-hub/suspended/@me.ts
+++ b/src/api/routes/safety-hub/suspended/@me.ts
@@ -38,7 +38,7 @@ router.get(
async (req: Request, res: Response) => {
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["data"],
+ select: { data: true },
});
res.send({
diff --git a/src/api/routes/teams.ts b/src/api/routes/teams.ts
index 090807d5..a9380f12 100644
--- a/src/api/routes/teams.ts
+++ b/src/api/routes/teams.ts
@@ -64,7 +64,7 @@ router.post(
async (req: Request, res: Response) => {
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["mfa_enabled"],
+ select: { mfa_enabled: true },
});
if (!user.mfa_enabled) throw new HTTPError("You must enable MFA to create a team");
diff --git a/src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts b/src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts
index 8846efe4..a85348ae 100644
--- a/src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts
+++ b/src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts
@@ -55,7 +55,18 @@ router.get("/", route({}), async (req: Request, res: Response) => {
external_id: connection_id,
user_id: req.user_id,
},
- select: ["external_id", "type", "name", "verified", "visibility", "show_activity", "revoked", "token_data", "friend_sync", "integrations"],
+ select: {
+ external_id: true,
+ type: true,
+ name: true,
+ verified: true,
+ visibility: true,
+ show_activity: true,
+ revoked: true,
+ token_data: true,
+ friend_sync: true,
+ integrations: true,
+ },
});
if (!connectedAccount) throw DiscordApiErrors.UNKNOWN_CONNECTION;
if (connectedAccount.revoked) throw DiscordApiErrors.CONNECTION_REVOKED;
diff --git a/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts b/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts
index 111312ae..718c80c0 100644
--- a/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts
+++ b/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts
@@ -33,7 +33,7 @@ router.patch("/", route({ requestBody: "ConnectionUpdateSchema" }), async (req:
external_id: connection_id,
type: connection_name,
},
- select: ["external_id", "type", "name", "verified", "visibility", "show_activity", "revoked", "friend_sync", "integrations"],
+ select: { external_id: true, type: true, name: true, verified: true, visibility: true, show_activity: true, revoked: true, friend_sync: true, integrations: true },
});
if (!connection) return DiscordApiErrors.UNKNOWN_CONNECTION;
diff --git a/src/api/routes/users/@me/connections/index.ts b/src/api/routes/users/@me/connections/index.ts
index a2d8b82a..fe2fbba0 100644
--- a/src/api/routes/users/@me/connections/index.ts
+++ b/src/api/routes/users/@me/connections/index.ts
@@ -27,7 +27,18 @@ router.get("/", route({}), async (req: Request, res: Response) => {
where: {
user_id: req.user_id,
},
- select: ["external_id", "type", "name", "verified", "visibility", "show_activity", "revoked", "token_data", "friend_sync", "integrations"],
+ select: {
+ external_id: true,
+ type: true,
+ name: true,
+ verified: true,
+ visibility: true,
+ show_activity: true,
+ revoked: true,
+ token_data: true,
+ friend_sync: true,
+ integrations: true,
+ },
});
res.json(connections.map((x) => new ConnectedAccountDTO(x, true)));
diff --git a/src/api/routes/users/@me/delete.ts b/src/api/routes/users/@me/delete.ts
index 668f7c19..749baf70 100644
--- a/src/api/routes/users/@me/delete.ts
+++ b/src/api/routes/users/@me/delete.ts
@@ -40,7 +40,7 @@ router.post(
async (req: Request, res: Response) => {
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["data"],
+ select: { data: true },
}); //User object
let correctpass = true;
diff --git a/src/api/routes/users/@me/disable.ts b/src/api/routes/users/@me/disable.ts
index 95995e4b..e95ec457 100644
--- a/src/api/routes/users/@me/disable.ts
+++ b/src/api/routes/users/@me/disable.ts
@@ -39,7 +39,7 @@ router.post(
async (req: Request, res: Response) => {
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["data"],
+ select: { data: true },
}); //User object
let correctpass = true;
diff --git a/src/api/routes/users/@me/guilds.ts b/src/api/routes/users/@me/guilds.ts
index c06c39c4..89086562 100644
--- a/src/api/routes/users/@me/guilds.ts
+++ b/src/api/routes/users/@me/guilds.ts
@@ -67,7 +67,7 @@ router.delete(
const { guild_id } = req.params;
const guild = await Guild.findOneOrFail({
where: { id: guild_id },
- select: ["owner_id"],
+ select: { owner_id: true },
});
if (!guild) throw new HTTPError("Guild doesn't exist", 404);
diff --git a/src/api/routes/users/@me/guilds/#guild_id/settings.ts b/src/api/routes/users/@me/guilds/#guild_id/settings.ts
index 16b64ec5..3aaf723e 100644
--- a/src/api/routes/users/@me/guilds/#guild_id/settings.ts
+++ b/src/api/routes/users/@me/guilds/#guild_id/settings.ts
@@ -35,7 +35,7 @@ router.get(
async (req: Request, res: Response) => {
const user = await Member.findOneOrFail({
where: { id: req.user_id, guild_id: req.params.guild_id },
- select: ["settings"],
+ select: { settings: true },
});
return res.json(user.settings);
},
@@ -66,7 +66,7 @@ router.patch(
const user = await Member.findOneOrFail({
where: { id: req.user_id, guild_id: req.params.guild_id },
- select: ["settings"],
+ select: { settings: true },
});
OrmUtils.mergeDeep(user.settings || {}, body);
Member.update({ id: req.user_id, guild_id: req.params.guild_id }, user);
diff --git a/src/api/routes/users/@me/mfa/codes.ts b/src/api/routes/users/@me/mfa/codes.ts
index 2eb1a3e3..0b1b94da 100644
--- a/src/api/routes/users/@me/mfa/codes.ts
+++ b/src/api/routes/users/@me/mfa/codes.ts
@@ -49,7 +49,7 @@ router.post(
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["data"],
+ select: { data: true },
});
if (!(await bcrypt.compare(password, user.data.hash || ""))) {
diff --git a/src/api/routes/users/@me/mfa/totp/disable.ts b/src/api/routes/users/@me/mfa/totp/disable.ts
index 11c927e4..0b195601 100644
--- a/src/api/routes/users/@me/mfa/totp/disable.ts
+++ b/src/api/routes/users/@me/mfa/totp/disable.ts
@@ -43,7 +43,7 @@ router.post(
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["totp_secret"],
+ select: { totp_secret: true },
});
const backup = await BackupCode.findOne({ where: { code: body.code } });
diff --git a/src/api/routes/users/@me/mfa/totp/enable.ts b/src/api/routes/users/@me/mfa/totp/enable.ts
index a400c628..869f1573 100644
--- a/src/api/routes/users/@me/mfa/totp/enable.ts
+++ b/src/api/routes/users/@me/mfa/totp/enable.ts
@@ -47,7 +47,7 @@ router.post(
const user = await User.findOneOrFail({
where: { id: req.user_id },
- select: ["data", "email"],
+ select: { data: true, email: true },
});
// TODO: Are guests allowed to enable 2fa?
diff --git a/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts b/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts
index 7bd29a57..50bf341c 100644
--- a/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts
+++ b/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts
@@ -80,7 +80,7 @@ router.post(
where: {
id: req.user_id,
},
- select: ["data", "id", "disabled", "deleted", "totp_secret", "mfa_enabled", "username"],
+ select: { data: true, id: true, disabled: true, deleted: true, totp_secret: true, mfa_enabled: true, username: true },
relations: ["settings"],
});
diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts
index 3f95daab..b796b29e 100644
--- a/src/api/routes/users/@me/relationships.ts
+++ b/src/api/routes/users/@me/relationships.ts
@@ -42,7 +42,7 @@ router.get(
const user = await User.findOneOrFail({
where: { id: req.user_id },
relations: ["relationships", "relationships.to"],
- select: ["id", "relationships"],
+ select: { id: true, relationships: true },
});
const related_users = user.relationships.map((r) => r.toPublicRelationship());
|