summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/applications/#application_id/bot/index.ts6
-rw-r--r--src/api/routes/applications/#application_id/commands/#command_id/index.ts16
-rw-r--r--src/api/routes/applications/#application_id/commands/index.ts24
-rw-r--r--src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts34
-rw-r--r--src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts44
-rw-r--r--src/api/routes/applications/#application_id/index.ts6
-rw-r--r--src/api/routes/channels/#channel_id/attachments.ts4
-rw-r--r--src/api/routes/channels/#channel_id/greet.ts2
-rw-r--r--src/api/routes/channels/#channel_id/index.ts6
-rw-r--r--src/api/routes/channels/#channel_id/invites.ts4
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/ack.ts2
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/index.ts8
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts26
-rw-r--r--src/api/routes/channels/#channel_id/messages/#message_id/threads.ts2
-rw-r--r--src/api/routes/channels/#channel_id/messages/bulk-delete.ts2
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts6
-rw-r--r--src/api/routes/channels/#channel_id/messages/pins/index.ts6
-rw-r--r--src/api/routes/channels/#channel_id/messages/search.ts4
-rw-r--r--src/api/routes/channels/#channel_id/permissions.ts4
-rw-r--r--src/api/routes/channels/#channel_id/pins.ts6
-rw-r--r--src/api/routes/channels/#channel_id/purge.ts2
-rw-r--r--src/api/routes/channels/#channel_id/recipients.ts4
-rw-r--r--src/api/routes/channels/#channel_id/thread-members.ts10
-rw-r--r--src/api/routes/channels/#channel_id/typing.ts2
-rw-r--r--src/api/routes/channels/#channel_id/webhooks.ts4
-rw-r--r--src/api/routes/connections/#connection_name/authorize.ts2
-rw-r--r--src/api/routes/connections/#connection_name/callback.ts2
-rw-r--r--src/api/routes/emojis/#emoji_id/source.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/application-command-index.ts4
-rw-r--r--src/api/routes/guilds/#guild_id/auto-moderation/rules.ts8
-rw-r--r--src/api/routes/guilds/#guild_id/bans.ts12
-rw-r--r--src/api/routes/guilds/#guild_id/bulk-ban.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/channels.ts6
-rw-r--r--src/api/routes/guilds/#guild_id/delete.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/discovery-requirements.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/emojis.ts10
-rw-r--r--src/api/routes/guilds/#guild_id/index.ts4
-rw-r--r--src/api/routes/guilds/#guild_id/invites.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/members/#member_id/index.ts12
-rw-r--r--src/api/routes/guilds/#guild_id/members/#member_id/nick.ts4
-rw-r--r--src/api/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts4
-rw-r--r--src/api/routes/guilds/#guild_id/members/index.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/messages/search.ts8
-rw-r--r--src/api/routes/guilds/#guild_id/profile.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/profile/index.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/prune.ts4
-rw-r--r--src/api/routes/guilds/#guild_id/regions.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/roles/#role_id/index.ts6
-rw-r--r--src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/roles/#role_id/members.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/roles/index.ts6
-rw-r--r--src/api/routes/guilds/#guild_id/roles/member-counts.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/shield.svg.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/stickers.ts10
-rw-r--r--src/api/routes/guilds/#guild_id/templates.ts10
-rw-r--r--src/api/routes/guilds/#guild_id/vanity-url.ts4
-rw-r--r--src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts4
-rw-r--r--src/api/routes/guilds/#guild_id/webhooks.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/welcome-screen.ts4
-rw-r--r--src/api/routes/guilds/#guild_id/widget.json.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/widget.png.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/widget.ts4
-rw-r--r--src/api/routes/guilds/templates/index.ts4
-rw-r--r--src/api/routes/interactions/#interaction_id/#interaction_token/callback.ts2
-rw-r--r--src/api/routes/invites/index.ts6
-rw-r--r--src/api/routes/oauth2/applications/@me.ts2
-rw-r--r--src/api/routes/partners/#guild_id/requirements.ts2
-rw-r--r--src/api/routes/stickers/#sticker_id/index.ts2
-rw-r--r--src/api/routes/store/published-listings/skus/#sku_id/subscription-plans.ts2
-rw-r--r--src/api/routes/users/#user_id/delete.ts18
-rw-r--r--src/api/routes/users/#user_id/index.ts2
-rw-r--r--src/api/routes/users/#user_id/messages.ts2
-rw-r--r--src/api/routes/users/#user_id/profile.ts2
-rw-r--r--src/api/routes/users/#user_id/relationships.ts2
-rw-r--r--src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts2
-rw-r--r--src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts4
-rw-r--r--src/api/routes/users/@me/guilds.ts2
-rw-r--r--src/api/routes/users/@me/guilds/#guild_id/settings.ts6
-rw-r--r--src/api/routes/users/@me/mfa/webauthn/credentials/#key_id/index.ts2
-rw-r--r--src/api/routes/users/@me/notes.ts4
-rw-r--r--src/api/routes/users/@me/relationships.ts6
-rw-r--r--src/api/routes/webhooks/#webhook_id/#token/index.ts6
-rw-r--r--src/api/routes/webhooks/#webhook_id/index.ts6
-rw-r--r--src/api/util/handlers/Webhook.ts2
-rw-r--r--src/api/util/handlers/route.ts3
85 files changed, 246 insertions, 237 deletions
diff --git a/src/api/routes/applications/#application_id/bot/index.ts b/src/api/routes/applications/#application_id/bot/index.ts

index 7f5369ae..47b8a729 100644 --- a/src/api/routes/applications/#application_id/bot/index.ts +++ b/src/api/routes/applications/#application_id/bot/index.ts
@@ -39,7 +39,7 @@ router.post( }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { owner: true }, }); @@ -66,7 +66,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const bot = await User.findOneOrFail({ where: { id: req.params.application_id } }); + const bot = await User.findOneOrFail({ where: { id: req.params.application_id as string } }); const owner = req.user; if (owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; @@ -110,7 +110,7 @@ router.patch( } const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { bot: true, owner: true }, }); diff --git a/src/api/routes/applications/#application_id/commands/#command_id/index.ts b/src/api/routes/applications/#application_id/commands/#command_id/index.ts
index 8e4c3ce9..55011042 100644 --- a/src/api/routes/applications/#application_id/commands/#command_id/index.ts +++ b/src/api/routes/applications/#application_id/commands/#command_id/index.ts
@@ -24,14 +24,14 @@ import { Application, ApplicationCommand, FieldErrors, Snowflake } from "@spaceb const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const command = await ApplicationCommand.findOne({ where: { application_id: req.params.application_id, id: req.params.command_id } }); + const command = await ApplicationCommand.findOne({ where: { application_id: req.params.application_id as string, id: req.params.command_id as string } }); if (!command) { res.status(404).send({ code: 404, message: "Unknown application command" }); @@ -47,14 +47,14 @@ router.patch( requestBody: "ApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, id: req.params.command_id } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id as string, id: req.params.command_id as string } }); if (!commandExists) { res.status(404).send({ code: 404, message: "Unknown application command" }); @@ -78,7 +78,7 @@ router.patch( } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, + application_id: req.params.application_id as string, name: body.name.trim(), name_localizations: body.name_localizations, description: body.description?.trim() || "", @@ -101,21 +101,21 @@ router.patch( ); router.delete("/", async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, id: req.params.command_id } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id as string, id: req.params.command_id as string } }); if (!commandExists) { res.status(404).send({ code: 404, message: "Unknown application command" }); return; } - await ApplicationCommand.delete({ application_id: req.params.application_id, id: req.params.command_id }); + await ApplicationCommand.delete({ application_id: req.params.application_id as string, id: req.params.command_id as string }); res.sendStatus(204); }); diff --git a/src/api/routes/applications/#application_id/commands/index.ts b/src/api/routes/applications/#application_id/commands/index.ts
index 91824be8..a3aaec2f 100644 --- a/src/api/routes/applications/#application_id/commands/index.ts +++ b/src/api/routes/applications/#application_id/commands/index.ts
@@ -25,14 +25,14 @@ import { IsNull } from "typeorm"; const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const command = await ApplicationCommand.find({ where: { application_id: req.params.application_id } }); + const command = await ApplicationCommand.find({ where: { application_id: req.params.application_id as string } }); res.send(command); }); @@ -42,7 +42,7 @@ router.post( requestBody: "ApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); @@ -66,7 +66,7 @@ router.post( } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, + application_id: req.params.application_id as string, name: body.name.trim(), name_localizations: body.name_localizations, description: body.description?.trim() || "", @@ -83,10 +83,10 @@ router.post( version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: body.name.trim() } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id as string, name: body.name.trim() } }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, name: body.name.trim() }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id as string, name: body.name.trim() }, commandForDb); } else { commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change await ApplicationCommand.save(commandForDb); @@ -102,7 +102,7 @@ router.put( requestBody: "BulkApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); @@ -112,13 +112,13 @@ router.put( const body = req.body as ApplicationCommandCreateSchema[]; // Remove commands not present in array - const applicationCommands = await ApplicationCommand.find({ where: { application_id: req.params.application_id, guild_id: IsNull() } }); + const applicationCommands = await ApplicationCommand.find({ where: { application_id: req.params.application_id as string, guild_id: IsNull() } }); const commandNamesInArray = body.map((c) => c.name); const commandsNotInArray = applicationCommands.filter((c) => !commandNamesInArray.includes(c.name)); for (const command of commandsNotInArray) { - await ApplicationCommand.delete({ application_id: req.params.application_id, guild_id: IsNull(), id: command.id }); + await ApplicationCommand.delete({ application_id: req.params.application_id as string, guild_id: IsNull(), id: command.id }); } for (const command of body) { @@ -137,7 +137,7 @@ router.put( } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, + application_id: req.params.application_id as string, name: command.name.trim(), name_localizations: command.name_localizations, description: command.description?.trim() || "", @@ -154,10 +154,10 @@ router.put( version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: command.name.trim() } }); + const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id as string, name: command.name.trim() } }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, name: command.name.trim() }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id as string, name: command.name.trim() }, commandForDb); } else { commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change await ApplicationCommand.save(commandForDb); diff --git a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts
index be2d62e7..e4f847c3 100644 --- a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts +++ b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts
@@ -24,26 +24,28 @@ import { Application, ApplicationCommand, FieldErrors, Guild, Member, Snowflake const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } - const command = await ApplicationCommand.findOne({ where: { application_id: req.params.application_id, id: req.params.command_id, guild_id: req.params.guild_id } }); + const command = await ApplicationCommand.findOne({ + where: { application_id: req.params.application_id as string, id: req.params.command_id as string, guild_id: req.params.guild_id as string }, + }); if (!command) { res.status(404).send({ code: 404, message: "Unknown application command" }); @@ -59,21 +61,21 @@ router.patch( requestBody: "ApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } @@ -95,7 +97,7 @@ router.patch( } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, + application_id: req.params.application_id as string, name: body.name.trim(), name_localizations: body.name_localizations, description: body.description?.trim() || "", @@ -113,7 +115,7 @@ router.patch( }; const commandExists = await ApplicationCommand.exists({ - where: { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name.trim() }, + where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: req.params.command_id as string, name: body.name.trim() }, }); if (!commandExists) { @@ -122,7 +124,7 @@ router.patch( } await ApplicationCommand.update( - { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name.trim() }, + { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: req.params.command_id as string, name: body.name.trim() }, commandForDb, ); res.send(commandForDb); @@ -130,33 +132,35 @@ router.patch( ); router.delete("/", async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id } }); + const commandExists = await ApplicationCommand.exists({ + where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: req.params.command_id as string }, + }); if (!commandExists) { res.status(404).send({ code: 404, message: "Unknown application command" }); return; } - await ApplicationCommand.delete({ application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id }); + await ApplicationCommand.delete({ application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: req.params.command_id as string }); res.sendStatus(204); }); diff --git a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts
index 607c846c..e51a4318 100644 --- a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts +++ b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts
@@ -24,26 +24,26 @@ import { Application, ApplicationCommand, FieldErrors, Guild, Member, Snowflake const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } - const command = await ApplicationCommand.find({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id } }); + const command = await ApplicationCommand.find({ where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string } }); res.send(command); }); @@ -53,21 +53,21 @@ router.post( requestBody: "ApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } @@ -89,8 +89,8 @@ router.post( } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, - guild_id: req.params.guild_id, + application_id: req.params.application_id as string, + guild_id: req.params.guild_id as string, name: body.name.trim(), name_localizations: body.name_localizations, description: body.description?.trim() || "", @@ -107,10 +107,12 @@ router.post( version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name.trim() } }); + const commandExists = await ApplicationCommand.exists({ + where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, name: body.name.trim() }, + }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name.trim() }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, name: body.name.trim() }, commandForDb); } else { commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change await ApplicationCommand.save(commandForDb); @@ -126,21 +128,21 @@ router.put( requestBody: "BulkApplicationCommandCreateSchema", }), async (req: Request, res: Response) => { - const applicationExists = await Application.exists({ where: { id: req.params.application_id } }); + const applicationExists = await Application.exists({ where: { id: req.params.application_id as string } }); if (!applicationExists) { res.status(404).send({ code: 404, message: "Unknown application" }); return; } - const guildExists = await Guild.exists({ where: { id: req.params.guild_id } }); + const guildExists = await Guild.exists({ where: { id: req.params.guild_id as string } }); if (!guildExists) { res.status(404).send({ code: 404, message: "Unknown Server" }); return; } - if (!(await Member.exists({ where: { id: req.params.application_id, guild_id: req.params.guild_id } }))) { + if (!(await Member.exists({ where: { id: req.params.application_id as string, guild_id: req.params.guild_id as string } }))) { res.status(401).send({ code: 401, message: "Missing Access" }); return; } @@ -148,13 +150,13 @@ router.put( const body = req.body as ApplicationCommandCreateSchema[]; // Remove commands not present in array - const applicationCommands = await ApplicationCommand.find({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id } }); + const applicationCommands = await ApplicationCommand.find({ where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string } }); const commandNamesInArray = body.map((c) => c.name); const commandsNotInArray = applicationCommands.filter((c) => !commandNamesInArray.includes(c.name)); for (const command of commandsNotInArray) { - await ApplicationCommand.delete({ application_id: req.params.application_id, guild_id: req.params.guild_id, id: command.id }); + await ApplicationCommand.delete({ application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, id: command.id }); } for (const command of body) { @@ -173,8 +175,8 @@ router.put( } const commandForDb: ApplicationCommandSchema = { - application_id: req.params.application_id, - guild_id: req.params.guild_id, + application_id: req.params.application_id as string, + guild_id: req.params.guild_id as string, name: command.name.trim(), name_localizations: command.name_localizations, description: command.description?.trim() || "", @@ -191,10 +193,12 @@ router.put( version: Snowflake.generate(), }; - const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, name: command.name } }); + const commandExists = await ApplicationCommand.exists({ + where: { application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, name: command.name }, + }); if (commandExists) { - await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, name: command.name }, commandForDb); + await ApplicationCommand.update({ application_id: req.params.application_id as string, guild_id: req.params.guild_id as string, name: command.name }, commandForDb); } else { commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change await ApplicationCommand.save(commandForDb); diff --git a/src/api/routes/applications/#application_id/index.ts b/src/api/routes/applications/#application_id/index.ts
index 58c01568..64fac23c 100644 --- a/src/api/routes/applications/#application_id/index.ts +++ b/src/api/routes/applications/#application_id/index.ts
@@ -39,7 +39,7 @@ router.get( }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { owner: true, bot: true }, }); if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; @@ -65,7 +65,7 @@ router.patch( const body = req.body as ApplicationModifySchema; const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { owner: true, bot: true }, }); @@ -122,7 +122,7 @@ router.post( }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.application_id }, + where: { id: req.params.application_id as string }, relations: { bot: true, owner: true }, }); if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; diff --git a/src/api/routes/channels/#channel_id/attachments.ts b/src/api/routes/channels/#channel_id/attachments.ts
index 0d5daa4c..bf3c70fb 100644 --- a/src/api/routes/channels/#channel_id/attachments.ts +++ b/src/api/routes/channels/#channel_id/attachments.ts
@@ -40,7 +40,7 @@ router.post( }), async (req: Request, res: Response) => { const payload = req.body as UploadAttachmentRequestSchema; - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const user = req.user; const channel = await Channel.findOneOrFail({ where: { id: channel_id } }); @@ -100,7 +100,7 @@ router.post( ); router.delete("/:cloud_attachment_url", async (req: Request, res: Response) => { - const { channel_id, cloud_attachment_url } = req.params; + const { channel_id, cloud_attachment_url } = req.params as { [key: string]: string }; const user = req.user; const channel = await Channel.findOneOrFail({ where: { id: channel_id } }); diff --git a/src/api/routes/channels/#channel_id/greet.ts b/src/api/routes/channels/#channel_id/greet.ts
index c3eaa76a..b556547d 100644 --- a/src/api/routes/channels/#channel_id/greet.ts +++ b/src/api/routes/channels/#channel_id/greet.ts
@@ -41,7 +41,7 @@ router.post( }), async (req: Request, res: Response) => { const payload = req.body as GreetRequestSchema; - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, diff --git a/src/api/routes/channels/#channel_id/index.ts b/src/api/routes/channels/#channel_id/index.ts
index bff5bb39..12333a7f 100644 --- a/src/api/routes/channels/#channel_id/index.ts +++ b/src/api/routes/channels/#channel_id/index.ts
@@ -37,7 +37,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -61,7 +61,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -147,7 +147,7 @@ router.patch( }), async (req: Request, res: Response) => { const payload = req.body as ChannelModifySchema; - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; if (payload.icon) payload.icon = await handleFile(`/channel-icons/${channel_id}`, payload.icon); const channel = await Channel.findOneOrFail({ diff --git a/src/api/routes/channels/#channel_id/invites.ts b/src/api/routes/channels/#channel_id/invites.ts
index be97e445..979d080d 100644 --- a/src/api/routes/channels/#channel_id/invites.ts +++ b/src/api/routes/channels/#channel_id/invites.ts
@@ -43,7 +43,7 @@ router.post( async (req: Request, res: Response) => { const { user_id } = req; const body = req.body as InviteCreateSchema; - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, select: { id: true, name: true, type: true, guild_id: true }, @@ -98,7 +98,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts b/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts
index 7b9f0397..8c34af5b 100644 --- a/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/ack.ts
@@ -36,7 +36,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const permission = await getPermission(req.user_id, undefined, channel_id); permission.hasThrow("VIEW_CHANNEL"); diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/index.ts b/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
index 7058bd3c..c0569124 100644 --- a/src/api/routes/channels/#channel_id/messages/#message_id/index.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/index.ts
@@ -67,7 +67,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; let body = req.body as MessageEditSchema; const message = await Message.findOneOrFail({ @@ -165,7 +165,7 @@ router.put( }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const body = req.body as MessageCreateSchema; const attachments: (MessageCreateAttachment | MessageCreateCloudAttachment)[] = body.attachments ?? []; @@ -261,7 +261,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, @@ -288,7 +288,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
index b21dbd34..88938063 100644 --- a/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/reactions.ts
@@ -68,7 +68,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -104,8 +104,8 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; - const emoji = getEmoji(req.params.emoji); + const { message_id, channel_id } = req.params as { [key: string]: string }; + const emoji = getEmoji(req.params.emoji as string); const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, @@ -149,8 +149,8 @@ router.get( }, }), async (req: Request, res: Response) => { - const { message_id, channel_id } = req.params; - const emoji = getEmoji(req.params.emoji); + const { message_id, channel_id } = req.params as { [key: string]: string }; + const emoji = getEmoji(req.params.emoji as string); const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, @@ -186,9 +186,9 @@ router.put( }, }), async (req: Request, res: Response) => { - const { message_id, channel_id, user_id } = req.params; + const { message_id, channel_id, user_id } = req.params as { [key: string]: string }; if (user_id !== "@me") throw new HTTPError("Invalid user"); - const emoji = getEmoji(req.params.emoji); + const emoji = getEmoji(req.params.emoji as string); const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -261,10 +261,10 @@ router.delete( }, }), async (req: Request, res: Response) => { - let { user_id } = req.params; - const { message_id, channel_id } = req.params; + let { user_id } = req.params as { [key: string]: string }; + const { message_id, channel_id } = req.params as { [key: string]: string }; - const emoji = getEmoji(req.params.emoji); + const emoji = getEmoji(req.params.emoji as string); const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -318,10 +318,10 @@ router.delete( }, }), async (req: Request, res: Response) => { - let { user_id } = req.params; - const { message_id, channel_id } = req.params; + let { user_id } = req.params as { [key: string]: string }; + const { message_id, channel_id } = req.params as { [key: string]: string }; - const emoji = getEmoji(req.params.emoji); + const emoji = getEmoji(req.params.emoji as string); const channel = await Channel.findOneOrFail({ where: { id: channel_id }, diff --git a/src/api/routes/channels/#channel_id/messages/#message_id/threads.ts b/src/api/routes/channels/#channel_id/messages/#message_id/threads.ts
index b70560ee..2f834851 100644 --- a/src/api/routes/channels/#channel_id/messages/#message_id/threads.ts +++ b/src/api/routes/channels/#channel_id/messages/#message_id/threads.ts
@@ -39,7 +39,7 @@ router.post( }), async (req: Request, res: Response) => { // TODO: check for differences with https://github.com/spacebarchat/server/pull/876/files#diff-95be9c4cdfd8ba6f67361cd40b9abc8226b35d83e2bb44bf5b4682f1d66155e9 - const { message_id, channel_id } = req.params; + const { message_id, channel_id } = req.params as { [key: string]: string }; const body = req.body as MessageThreadCreationSchema; const message = await Message.findOneOrFail({ where: { id: message_id, channel_id }, diff --git a/src/api/routes/channels/#channel_id/messages/bulk-delete.ts b/src/api/routes/channels/#channel_id/messages/bulk-delete.ts
index f4645abd..8c543ad5 100644 --- a/src/api/routes/channels/#channel_id/messages/bulk-delete.ts +++ b/src/api/routes/channels/#channel_id/messages/bulk-delete.ts
@@ -42,7 +42,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts
index 110e8901..74e30aad 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -97,7 +97,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const channel_id = req.params.channel_id; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); @@ -329,7 +329,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const body = req.body as MessageCreateSchema; const attachments: (Attachment | MessageCreateAttachment | MessageCreateCloudAttachment)[] = body.attachments ?? []; @@ -518,7 +518,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; // not really a channel id if read_state_type != CHANNEL + const { channel_id } = req.params as { [key: string]: string }; // not really a channel id if read_state_type != CHANNEL const body = req.body as AcknowledgeDeleteSchema; if (body.version != 2) return res.status(204).send(); // TODO: handle other read state types diff --git a/src/api/routes/channels/#channel_id/messages/pins/index.ts b/src/api/routes/channels/#channel_id/messages/pins/index.ts
index 3316d156..9c6299df 100644 --- a/src/api/routes/channels/#channel_id/messages/pins/index.ts +++ b/src/api/routes/channels/#channel_id/messages/pins/index.ts
@@ -37,7 +37,7 @@ router.put( }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id }, @@ -122,7 +122,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id }, @@ -169,7 +169,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const pins = await Message.find({ where: { channel_id: channel_id, pinned_at: Not(IsNull()) }, diff --git a/src/api/routes/channels/#channel_id/messages/search.ts b/src/api/routes/channels/#channel_id/messages/search.ts
index 1a371cc7..77ec46c7 100644 --- a/src/api/routes/channels/#channel_id/messages/search.ts +++ b/src/api/routes/channels/#channel_id/messages/search.ts
@@ -42,9 +42,9 @@ router.get( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ - where: { guild_id: req.params.guild_id }, + where: { guild_id: req.params.guild_id as string }, select: { id: true }, }); const { diff --git a/src/api/routes/channels/#channel_id/permissions.ts b/src/api/routes/channels/#channel_id/permissions.ts
index c03ca03f..3b7e1349 100644 --- a/src/api/routes/channels/#channel_id/permissions.ts +++ b/src/api/routes/channels/#channel_id/permissions.ts
@@ -39,7 +39,7 @@ router.put( }, }), async (req: Request, res: Response) => { - const { channel_id, overwrite_id } = req.params; + const { channel_id, overwrite_id } = req.params as { [key: string]: string }; const body = req.body as ChannelPermissionOverwriteSchema; const channel = await Channel.findOneOrFail({ @@ -82,7 +82,7 @@ router.put( // TODO: check permission hierarchy router.delete("/:overwrite_id", route({ permission: "MANAGE_ROLES", responses: { 204: {}, 404: {} } }), async (req: Request, res: Response) => { - const { channel_id, overwrite_id } = req.params; + const { channel_id, overwrite_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, diff --git a/src/api/routes/channels/#channel_id/pins.ts b/src/api/routes/channels/#channel_id/pins.ts
index d94d4f37..37021676 100644 --- a/src/api/routes/channels/#channel_id/pins.ts +++ b/src/api/routes/channels/#channel_id/pins.ts
@@ -38,7 +38,7 @@ router.put( }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id }, @@ -123,7 +123,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { channel_id, message_id } = req.params; + const { channel_id, message_id } = req.params as { [key: string]: string }; const message = await Message.findOneOrFail({ where: { id: message_id }, @@ -170,7 +170,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const pins = await Message.find({ where: { channel_id: channel_id, pinned_at: Not(IsNull()) }, diff --git a/src/api/routes/channels/#channel_id/purge.ts b/src/api/routes/channels/#channel_id/purge.ts
index 90f8c6d4..bbfb51fa 100644 --- a/src/api/routes/channels/#channel_id/purge.ts +++ b/src/api/routes/channels/#channel_id/purge.ts
@@ -44,7 +44,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); diff --git a/src/api/routes/channels/#channel_id/recipients.ts b/src/api/routes/channels/#channel_id/recipients.ts
index c001f843..71caa9ee 100644 --- a/src/api/routes/channels/#channel_id/recipients.ts +++ b/src/api/routes/channels/#channel_id/recipients.ts
@@ -32,7 +32,7 @@ router.put( }, }), async (req: Request, res: Response) => { - const { channel_id, user_id } = req.params; + const { channel_id, user_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, relations: { recipients: true }, @@ -82,7 +82,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { channel_id, user_id } = req.params; + const { channel_id, user_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, relations: { recipients: true }, diff --git a/src/api/routes/channels/#channel_id/thread-members.ts b/src/api/routes/channels/#channel_id/thread-members.ts
index 3e42f307..685252a8 100644 --- a/src/api/routes/channels/#channel_id/thread-members.ts +++ b/src/api/routes/channels/#channel_id/thread-members.ts
@@ -41,7 +41,7 @@ router.get( after?: Snowflake; limit?: string; }; - const { id: channel_id } = req.params; + const { id: channel_id } = req.params as { [key: string]: string }; if (limit && parseInt(limit) > 100) limit = "100"; @@ -69,7 +69,7 @@ router.post( }), async (req: Request, res: Response) => { // eslint-disable-next-line prefer-const - let { channel_id, user_id } = req.params; + let { channel_id, user_id } = req.params as { [key: string]: string }; const thread = await Channel.findOneOrFail({ where: { id: channel_id } }); if (user_id != "@me") (await thread.getUserPermissions({ user: req.user, guild: thread.guild })).hasThrow(Permissions.FLAGS.SEND_MESSAGES); @@ -126,7 +126,7 @@ router.delete( }), async (req: Request, res: Response) => { // eslint-disable-next-line prefer-const - let { channel_id, user_id } = req.params; + let { channel_id, user_id } = req.params as { [key: string]: string }; const thread = await Channel.findOneOrFail({ where: { id: channel_id } }); // TODO: require thread creator for private threads @@ -181,9 +181,9 @@ router.patch( async (req: Request, res: Response) => { // TODO // eslint-disable-next-line prefer-const - let { channel_id } = req.params; + let { channel_id } = req.params as { [key: string]: string }; const thread = await Channel.findOneOrFail({ where: { id: channel_id } }); - await Member.IsInGuildOrFail(req.params.user_id, thread.guild_id!); + await Member.IsInGuildOrFail(req.params.user_id as string, thread.guild_id!); // var threadMember = await ThreadMember.findOneOrFail({ where: { member_id: req.user_id, id: channel_id } }); // await emitEvent({ diff --git a/src/api/routes/channels/#channel_id/typing.ts b/src/api/routes/channels/#channel_id/typing.ts
index b5b2cd1e..d5890fcb 100644 --- a/src/api/routes/channels/#channel_id/typing.ts +++ b/src/api/routes/channels/#channel_id/typing.ts
@@ -33,7 +33,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const user_id = req.user_id; const timestamp = Math.floor(Date.now() / 1000); const channel = await Channel.findOneOrFail({ diff --git a/src/api/routes/channels/#channel_id/webhooks.ts b/src/api/routes/channels/#channel_id/webhooks.ts
index 994bab2f..23537b7d 100644 --- a/src/api/routes/channels/#channel_id/webhooks.ts +++ b/src/api/routes/channels/#channel_id/webhooks.ts
@@ -37,7 +37,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { channel_id } = req.params; + const { channel_id } = req.params as { [key: string]: string }; const webhooks = await Webhook.find({ where: { channel_id }, relations: { user: true, channel: true, source_channel: true, guild: true, source_guild: true, application: true }, @@ -69,7 +69,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const channel_id = req.params.channel_id; + const { channel_id } = req.params as { [key: string]: string }; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, }); diff --git a/src/api/routes/connections/#connection_name/authorize.ts b/src/api/routes/connections/#connection_name/authorize.ts
index 1efb6564..ca56bbe3 100644 --- a/src/api/routes/connections/#connection_name/authorize.ts +++ b/src/api/routes/connections/#connection_name/authorize.ts
@@ -23,7 +23,7 @@ import { ConnectionStore, FieldErrors } from "../../../../util"; const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const { connection_name } = req.params; + const { connection_name } = req.params as { [key: string]: string }; const connection = ConnectionStore.connections.get(connection_name); if (!connection) throw FieldErrors({ diff --git a/src/api/routes/connections/#connection_name/callback.ts b/src/api/routes/connections/#connection_name/callback.ts
index a83882ca..2f6a25a0 100644 --- a/src/api/routes/connections/#connection_name/callback.ts +++ b/src/api/routes/connections/#connection_name/callback.ts
@@ -24,7 +24,7 @@ import { ConnectionCallbackSchema } from "@spacebar/schemas"; const router = Router({ mergeParams: true }); router.post("/", route({ requestBody: "ConnectionCallbackSchema" }), async (req: Request, res: Response) => { - const { connection_name } = req.params; + const { connection_name } = req.params as { [key: string]: string }; const connection = ConnectionStore.connections.get(connection_name); if (!connection) throw FieldErrors({ diff --git a/src/api/routes/emojis/#emoji_id/source.ts b/src/api/routes/emojis/#emoji_id/source.ts
index f5c4a830..10fdba0d 100644 --- a/src/api/routes/emojis/#emoji_id/source.ts +++ b/src/api/routes/emojis/#emoji_id/source.ts
@@ -36,7 +36,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { emoji_id } = req.params; + const { emoji_id } = req.params as { [key: string]: string }; const emoji = await Emoji.findOne({ where: { id: emoji_id } }); if (!emoji) { diff --git a/src/api/routes/guilds/#guild_id/application-command-index.ts b/src/api/routes/guilds/#guild_id/application-command-index.ts
index 244029d5..d5b8d6e6 100644 --- a/src/api/routes/guilds/#guild_id/application-command-index.ts +++ b/src/api/routes/guilds/#guild_id/application-command-index.ts
@@ -25,7 +25,7 @@ import { ApplicationCommandSchema, ApplicationCommandType } from "@spacebar/sche const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const members = await Member.find({ where: { guild_id: req.params.guild_id, user: { bot: true } } }); + const members = await Member.find({ where: { guild_id: req.params.guild_id as string, user: { bot: true } } }); const applications: Application[] = []; for (const member of members) { @@ -50,7 +50,7 @@ router.get("/", route({}), async (req: Request, res: Response) => { for (const application of applications) { applicationCommands.push(await ApplicationCommand.find({ where: { application_id: application.id, guild_id: IsNull() } })); - applicationCommands.push(await ApplicationCommand.find({ where: { application_id: application.id, guild_id: req.params.guild_id } })); + applicationCommands.push(await ApplicationCommand.find({ where: { application_id: application.id, guild_id: req.params.guild_id as string } })); } const applicationCommandsSendable: ApplicationCommandSchema[] = []; diff --git a/src/api/routes/guilds/#guild_id/auto-moderation/rules.ts b/src/api/routes/guilds/#guild_id/auto-moderation/rules.ts
index 8c24651d..8b56ded9 100644 --- a/src/api/routes/guilds/#guild_id/auto-moderation/rules.ts +++ b/src/api/routes/guilds/#guild_id/auto-moderation/rules.ts
@@ -38,7 +38,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const rules = await AutomodRule.find({ where: { guild_id } }); return res.json(rules); }, @@ -62,7 +62,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; if (req.user_id !== req.body.creator_id) throw new HTTPError("You can't create a rule for someone else", 403); if (guild_id !== req.body.guild_id) throw new HTTPError("You can't create a rule for another guild", 403); @@ -103,7 +103,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { rule_id } = req.params; + const { rule_id } = req.params as { [key: string]: string }; const rule = await AutomodRule.findOneOrFail({ where: { id: rule_id }, }); @@ -131,7 +131,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { rule_id } = req.params; + const { rule_id } = req.params as { [key: string]: string }; await AutomodRule.delete({ id: rule_id }); return res.status(204).send(); }, diff --git a/src/api/routes/guilds/#guild_id/bans.ts b/src/api/routes/guilds/#guild_id/bans.ts
index 2bd28ace..6fa34d35 100644 --- a/src/api/routes/guilds/#guild_id/bans.ts +++ b/src/api/routes/guilds/#guild_id/bans.ts
@@ -40,7 +40,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let bans = await Ban.find({ where: { guild_id: guild_id } }); const promisesToAwait: Promise<PublicUser>[] = []; @@ -98,7 +98,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const limit = Number(req.query.limit) || 10; if (limit > 10 || limit < 1) throw new HTTPError("Limit must be between 1 and 10"); @@ -154,7 +154,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id, user_id } = req.params; + const { guild_id, user_id } = req.params as { [key: string]: string }; const ban = (await Ban.findOneOrFail({ where: { guild_id: guild_id, user_id: user_id }, @@ -196,8 +196,8 @@ router.put( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; - const banned_user_id = req.params.user_id; + const { guild_id } = req.params as { [key: string]: string }; + const banned_user_id = req.params.user_id as string; const opts = req.body as BanCreateSchema; let deleteMessagesMs = opts.delete_message_days @@ -262,7 +262,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { guild_id, user_id } = req.params; + const { guild_id, user_id } = req.params as { [key: string]: string }; await Ban.findOneOrFail({ where: { guild_id: guild_id, user_id: user_id }, diff --git a/src/api/routes/guilds/#guild_id/bulk-ban.ts b/src/api/routes/guilds/#guild_id/bulk-ban.ts
index 41e14ebd..67b23ba5 100644 --- a/src/api/routes/guilds/#guild_id/bulk-ban.ts +++ b/src/api/routes/guilds/#guild_id/bulk-ban.ts
@@ -42,7 +42,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const userIds: Array<string> = req.body.user_ids; if (!userIds) throw new HTTPError("The user_ids array is missing", 400); diff --git a/src/api/routes/guilds/#guild_id/channels.ts b/src/api/routes/guilds/#guild_id/channels.ts
index fc374acb..57bc8183 100644 --- a/src/api/routes/guilds/#guild_id/channels.ts +++ b/src/api/routes/guilds/#guild_id/channels.ts
@@ -32,7 +32,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const channels = await Channel.find({ where: { guild_id } }); for await (const channel of channels) { @@ -63,7 +63,7 @@ router.post( }), async (req: Request, res: Response) => { // creates a new guild channel https://discord.com/developers/docs/resources/guild#create-guild-channel - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as ChannelModifySchema; const channel = await Channel.createChannel({ ...body, guild_id }, req.user_id); @@ -90,7 +90,7 @@ router.patch( }), async (req: Request, res: Response) => { // changes guild channel position - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let body = req.body as ChannelReorderSchema; const guild = await Guild.findOneOrFail({ diff --git a/src/api/routes/guilds/#guild_id/delete.ts b/src/api/routes/guilds/#guild_id/delete.ts
index 6e541da1..1557c172 100644 --- a/src/api/routes/guilds/#guild_id/delete.ts +++ b/src/api/routes/guilds/#guild_id/delete.ts
@@ -39,7 +39,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id }, diff --git a/src/api/routes/guilds/#guild_id/discovery-requirements.ts b/src/api/routes/guilds/#guild_id/discovery-requirements.ts
index 25512769..d11d9d91 100644 --- a/src/api/routes/guilds/#guild_id/discovery-requirements.ts +++ b/src/api/routes/guilds/#guild_id/discovery-requirements.ts
@@ -31,7 +31,7 @@ router.get( }, }), (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; // TODO: // Load from database // Admin control, but for now it allows anyone to be discoverable diff --git a/src/api/routes/guilds/#guild_id/emojis.ts b/src/api/routes/guilds/#guild_id/emojis.ts
index 663ce417..1044b8a4 100644 --- a/src/api/routes/guilds/#guild_id/emojis.ts +++ b/src/api/routes/guilds/#guild_id/emojis.ts
@@ -36,7 +36,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); @@ -65,7 +65,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id, emoji_id } = req.params; + const { guild_id, emoji_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); @@ -96,7 +96,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as EmojiCreateSchema; const id = Snowflake.generate(); @@ -153,7 +153,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { emoji_id, guild_id } = req.params; + const { emoji_id, guild_id } = req.params as { [key: string]: string }; const body = req.body as EmojiModifySchema; if (body.name?.includes("-")) body.name = body.name?.replaceAll("-", ""); // Dashes are invalid apparently @@ -189,7 +189,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { emoji_id, guild_id } = req.params; + const { emoji_id, guild_id } = req.params as { [key: string]: string }; await Emoji.delete({ id: emoji_id, diff --git a/src/api/routes/guilds/#guild_id/index.ts b/src/api/routes/guilds/#guild_id/index.ts
index 8bb9e7df..2bfa9c87 100644 --- a/src/api/routes/guilds/#guild_id/index.ts +++ b/src/api/routes/guilds/#guild_id/index.ts
@@ -40,7 +40,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const [guild, member] = await Promise.all([Guild.findOneOrFail({ where: { id: guild_id } }), Member.findOne({ where: { guild_id: guild_id, id: req.user_id } })]); if (!member) throw new HTTPError("You are not a member of the guild you are trying to access", 401); @@ -74,7 +74,7 @@ router.patch( }), async (req: Request, res: Response) => { const body = req.body as GuildUpdateSchema; - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const rights = await getRights(req.user_id); const permission = await getPermission(req.user_id, guild_id); diff --git a/src/api/routes/guilds/#guild_id/invites.ts b/src/api/routes/guilds/#guild_id/invites.ts
index 32d86a4a..656d06d6 100644 --- a/src/api/routes/guilds/#guild_id/invites.ts +++ b/src/api/routes/guilds/#guild_id/invites.ts
@@ -33,7 +33,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const invites = await Invite.find({ where: { guild_id }, diff --git a/src/api/routes/guilds/#guild_id/members/#member_id/index.ts b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
index 7049857e..2ccece6b 100644 --- a/src/api/routes/guilds/#guild_id/members/#member_id/index.ts +++ b/src/api/routes/guilds/#guild_id/members/#member_id/index.ts
@@ -39,7 +39,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id, member_id } = req.params; + const { guild_id, member_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); const member = await Member.findOneOrFail({ @@ -85,8 +85,8 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; - const member_id = req.params.member_id === "@me" ? req.user_id : req.params.member_id; + const { guild_id } = req.params as { [key: string]: string }; + const member_id = req.params.member_id === "@me" ? req.user_id : (req.params.member_id as string); const body = req.body as MemberChangeSchema; const member = await Member.findOneOrFail({ @@ -168,8 +168,8 @@ router.put( const rights = await getRights(req.user_id); - const { guild_id } = req.params; - let { member_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; + let { member_id } = req.params as { [key: string]: string }; if (member_id === "@me") { member_id = req.user_id; rights.hasThrow("JOIN_GUILDS"); @@ -216,7 +216,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { guild_id, member_id } = req.params; + const { guild_id, member_id } = req.params as { [key: string]: string }; const permission = await getPermission(req.user_id, guild_id); const rights = await getRights(req.user_id); if (member_id === "@me" || member_id === req.user_id) { diff --git a/src/api/routes/guilds/#guild_id/members/#member_id/nick.ts b/src/api/routes/guilds/#guild_id/members/#member_id/nick.ts
index 87c95aa3..0e6a7465 100644 --- a/src/api/routes/guilds/#guild_id/members/#member_id/nick.ts +++ b/src/api/routes/guilds/#guild_id/members/#member_id/nick.ts
@@ -39,9 +39,9 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let permissionString: PermissionResolvable = "MANAGE_NICKNAMES"; - const member_id = req.params.member_id === "@me" ? ((permissionString = "CHANGE_NICKNAME"), req.user_id) : req.params.member_id; + const member_id = req.params.member_id === "@me" ? ((permissionString = "CHANGE_NICKNAME"), req.user_id) : (req.params.member_id as string); const perms = await getPermission(req.user_id, guild_id); perms.hasThrow(permissionString); diff --git a/src/api/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts b/src/api/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
index d482c06e..ccfc37b1 100644 --- a/src/api/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts +++ b/src/api/routes/guilds/#guild_id/members/#member_id/roles/#role_id/index.ts
@@ -34,7 +34,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { guild_id, role_id, member_id } = req.params; + const { guild_id, role_id, member_id } = req.params as { [key: string]: string }; await Member.removeRole(member_id, guild_id, role_id); res.sendStatus(204); @@ -51,7 +51,7 @@ router.put( }, }), async (req: Request, res: Response) => { - const { guild_id, role_id, member_id } = req.params; + const { guild_id, role_id, member_id } = req.params as { [key: string]: string }; await Member.addRole(member_id, guild_id, role_id); res.sendStatus(204); diff --git a/src/api/routes/guilds/#guild_id/members/index.ts b/src/api/routes/guilds/#guild_id/members/index.ts
index 08b77076..78a35d8f 100644 --- a/src/api/routes/guilds/#guild_id/members/index.ts +++ b/src/api/routes/guilds/#guild_id/members/index.ts
@@ -50,7 +50,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: 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}`; diff --git a/src/api/routes/guilds/#guild_id/messages/search.ts b/src/api/routes/guilds/#guild_id/messages/search.ts
index 51c9b5a2..166b87e3 100644 --- a/src/api/routes/guilds/#guild_id/messages/search.ts +++ b/src/api/routes/guilds/#guild_id/messages/search.ts
@@ -66,7 +66,7 @@ router.get( }); // todo this is wrong } - const permissions = await getPermission(req.user_id, req.params.guild_id, channel_id as string | undefined); + const permissions = await getPermission(req.user_id, req.params.guild_id as string, channel_id as string | undefined); permissions.hasThrow("VIEW_CHANNEL"); if (!permissions.has("READ_MESSAGE_HISTORY")) return res.json({ messages: [], total_results: 0 }); @@ -77,7 +77,7 @@ router.get( take: parsedLimit || 0, where: { guild: { - id: req.params.guild_id, + id: req.params.guild_id as string, }, }, relations: { author: true, webhook: true, application: true, mentions: true, mention_roles: true, mention_channels: true, sticker_items: true, attachments: true }, @@ -88,13 +88,13 @@ router.get( else { // get all channel IDs that this user can access const channels = await Channel.find({ - where: { guild_id: req.params.guild_id }, + where: { guild_id: req.params.guild_id as string }, select: { id: true }, }); const ids = []; for (const channel of channels) { - const perm = await getPermission(req.user_id, req.params.guild_id, channel.id); + const perm = await getPermission(req.user_id, req.params.guild_id as string, channel.id); if (!perm.has("VIEW_CHANNEL") || !perm.has("READ_MESSAGE_HISTORY")) continue; ids.push(channel.id); } diff --git a/src/api/routes/guilds/#guild_id/profile.ts b/src/api/routes/guilds/#guild_id/profile.ts
index 176c612c..8bbdce1d 100644 --- a/src/api/routes/guilds/#guild_id/profile.ts +++ b/src/api/routes/guilds/#guild_id/profile.ts
@@ -33,7 +33,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); const profileResponse: GuildProfileResponse = { id: guild_id, diff --git a/src/api/routes/guilds/#guild_id/profile/index.ts b/src/api/routes/guilds/#guild_id/profile/index.ts
index b7a071b7..0e35aac1 100644 --- a/src/api/routes/guilds/#guild_id/profile/index.ts +++ b/src/api/routes/guilds/#guild_id/profile/index.ts
@@ -40,7 +40,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; // const member_id = // req.params.member_id === "@me" ? req.user_id : req.params.member_id; const body = req.body as MemberChangeProfileSchema; diff --git a/src/api/routes/guilds/#guild_id/prune.ts b/src/api/routes/guilds/#guild_id/prune.ts
index 71791479..e2504bf6 100644 --- a/src/api/routes/guilds/#guild_id/prune.ts +++ b/src/api/routes/guilds/#guild_id/prune.ts
@@ -87,7 +87,7 @@ router.get( let roles = req.query.include_roles; if (typeof roles === "string") roles = [roles]; //express will return array otherwise - const members = await inactiveMembers(req.params.guild_id, req.user_id, days, roles as string[]); + const members = await inactiveMembers(req.params.guild_id as string, req.user_id, days, roles as string[]); res.send({ pruned: members.length }); }, @@ -113,7 +113,7 @@ router.post( let roles = req.query.include_roles; if (typeof roles === "string") roles = [roles]; - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const members = await inactiveMembers(guild_id, req.user_id, days, roles as string[]); await Promise.all(members.map((x) => Member.removeFromGuild(x.id, guild_id))); diff --git a/src/api/routes/guilds/#guild_id/regions.ts b/src/api/routes/guilds/#guild_id/regions.ts
index b2a311d7..66c1e685 100644 --- a/src/api/routes/guilds/#guild_id/regions.ts +++ b/src/api/routes/guilds/#guild_id/regions.ts
@@ -35,7 +35,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); //TODO we should use an enum for guild's features and not hardcoded strings return res.json(await getVoiceRegions(req.ip!, guild.features.includes("VIP_REGIONS"))); diff --git a/src/api/routes/guilds/#guild_id/roles/#role_id/index.ts b/src/api/routes/guilds/#guild_id/roles/#role_id/index.ts
index 1811284a..af2d3a37 100644 --- a/src/api/routes/guilds/#guild_id/roles/#role_id/index.ts +++ b/src/api/routes/guilds/#guild_id/roles/#role_id/index.ts
@@ -40,7 +40,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id, role_id } = req.params; + const { guild_id, role_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); const role = await Role.findOneOrFail({ where: { guild_id, id: role_id }, @@ -67,7 +67,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { guild_id, role_id } = req.params; + const { guild_id, role_id } = req.params as { [key: string]: string }; if (role_id === guild_id) throw new HTTPError("You can't delete the @everyone role"); await Promise.all([ @@ -112,7 +112,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { role_id, guild_id } = req.params; + const { role_id, guild_id } = req.params as { [key: string]: string }; const body = req.body as RoleModifySchema; if (body.icon && body.icon.length) body.icon = await handleFile(`/role-icons/${role_id}`, body.icon as string); 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 e4dccb3e..afa8d189 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
@@ -23,7 +23,7 @@ import { route } from "@spacebar/api"; const router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const { guild_id, role_id } = req.params; + const { guild_id, role_id } = req.params as { [key: string]: string }; // TODO: Is this route really not paginated? const members = await Member.find({ diff --git a/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts b/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts
index 6eb6804c..aea54b1d 100644 --- a/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts +++ b/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts
@@ -24,7 +24,7 @@ const router = Router({ mergeParams: true }); router.patch("/", route({ permission: "MANAGE_ROLES" }), async (req: Request, res: Response) => { // Payload is JSON containing a list of member_ids, the new list of members to have the role - const { guild_id, role_id } = req.params; + const { guild_id, role_id } = req.params as { [key: string]: string }; const { member_ids } = req.body; // don't mess with @everyone diff --git a/src/api/routes/guilds/#guild_id/roles/index.ts b/src/api/routes/guilds/#guild_id/roles/index.ts
index 8caea56f..b8e2b1a3 100644 --- a/src/api/routes/guilds/#guild_id/roles/index.ts +++ b/src/api/routes/guilds/#guild_id/roles/index.ts
@@ -25,7 +25,7 @@ import { RoleModifySchema, RolePositionUpdateSchema } from "@spacebar/schemas"; const router: Router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const guild_id = req.params.guild_id; + const guild_id = req.params.guild_id as string; await Member.IsInGuildOrFail(req.user_id, guild_id); @@ -52,7 +52,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const guild_id = req.params.guild_id; + const guild_id = req.params.guild_id as string; const body = req.body as RoleModifySchema; const role_count = await Role.count({ where: { guild_id } }); @@ -124,7 +124,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as RolePositionUpdateSchema; await Promise.all(body.map(async (x) => Role.update({ guild_id, id: x.id }, { position: x.position }))); 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 0f3a12ce..59783c3a 100644 --- a/src/api/routes/guilds/#guild_id/roles/member-counts.ts +++ b/src/api/routes/guilds/#guild_id/roles/member-counts.ts
@@ -23,7 +23,7 @@ import { route } from "@spacebar/api"; const router: Router = Router({ mergeParams: true }); router.get("/", route({}), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); const role_ids = await Role.find({ where: { guild_id }, select: { id: true } }); diff --git a/src/api/routes/guilds/#guild_id/shield.svg.ts b/src/api/routes/guilds/#guild_id/shield.svg.ts
index aaf7bced..bb5e1c7d 100644 --- a/src/api/routes/guilds/#guild_id/shield.svg.ts +++ b/src/api/routes/guilds/#guild_id/shield.svg.ts
@@ -51,7 +51,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let cacheEntry = jsonDataCache.get(guild_id); if (!cacheEntry || cacheEntry.expiry.getTime() < Date.now()) { diff --git a/src/api/routes/guilds/#guild_id/stickers.ts b/src/api/routes/guilds/#guild_id/stickers.ts
index dd1498e7..857713de 100644 --- a/src/api/routes/guilds/#guild_id/stickers.ts +++ b/src/api/routes/guilds/#guild_id/stickers.ts
@@ -37,7 +37,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); res.json(await Sticker.find({ where: { guild_id } })); @@ -74,7 +74,7 @@ router.post( async (req: Request, res: Response) => { if (!req.file) throw new HTTPError("missing file"); - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as ModifyGuildStickerSchema; const id = Snowflake.generate(); @@ -132,7 +132,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id, sticker_id } = req.params; + const { guild_id, sticker_id } = req.params as { [key: string]: string }; await Member.IsInGuildOrFail(req.user_id, guild_id); res.json( @@ -161,7 +161,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { guild_id, sticker_id } = req.params; + const { guild_id, sticker_id } = req.params as { [key: string]: string }; const body = req.body as ModifyGuildStickerSchema; const sticker = await Sticker.create({ @@ -198,7 +198,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { guild_id, sticker_id } = req.params; + const { guild_id, sticker_id } = req.params as { [key: string]: string }; await Sticker.delete({ guild_id, id: sticker_id }); await sendStickerUpdateEvent(guild_id); diff --git a/src/api/routes/guilds/#guild_id/templates.ts b/src/api/routes/guilds/#guild_id/templates.ts
index e577cead..54b7fce2 100644 --- a/src/api/routes/guilds/#guild_id/templates.ts +++ b/src/api/routes/guilds/#guild_id/templates.ts
@@ -51,7 +51,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const templates = await Template.find({ where: { source_guild_id: guild_id }, @@ -82,7 +82,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id }, select: TemplateGuildProjection, @@ -117,7 +117,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { code, guild_id } = req.params; + const { code, guild_id } = req.params as { [key: string]: string }; const template = await Template.delete({ code, @@ -138,7 +138,7 @@ router.put( }, }), async (req: Request, res: Response) => { - const { code, guild_id } = req.params; + const { code, guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id }, select: TemplateGuildProjection, @@ -164,7 +164,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { code, guild_id } = req.params; + const { code, guild_id } = req.params as { [key: string]: string }; const { name, description } = req.body; const template = await Template.findOneOrFail({ diff --git a/src/api/routes/guilds/#guild_id/vanity-url.ts b/src/api/routes/guilds/#guild_id/vanity-url.ts
index e622c255..ec3f0ab5 100644 --- a/src/api/routes/guilds/#guild_id/vanity-url.ts +++ b/src/api/routes/guilds/#guild_id/vanity-url.ts
@@ -43,7 +43,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); if (!guild.features.includes("ALIASABLE_NAMES")) { @@ -82,7 +82,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const body = req.body as VanityUrlSchema; const code = body.code?.replace(InviteRegex, ""); diff --git a/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts b/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts
index 5283ae01..95c39283 100644 --- a/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts +++ b/src/api/routes/guilds/#guild_id/voice-states/#user_id/index.ts
@@ -43,8 +43,8 @@ router.patch( }), async (req: Request, res: Response) => { const body = req.body as VoiceStateUpdateSchema; - const { guild_id } = req.params; - const user_id = req.params.user_id === "@me" ? req.user_id : req.params.user_id; + const { guild_id } = req.params as { [key: string]: string }; + const user_id = req.params.user_id === "@me" ? req.user_id : (req.params.user_id as string); const perms = await getPermission(req.user_id, guild_id, body.channel_id); diff --git a/src/api/routes/guilds/#guild_id/webhooks.ts b/src/api/routes/guilds/#guild_id/webhooks.ts
index 65fa0ab2..cb717f90 100644 --- a/src/api/routes/guilds/#guild_id/webhooks.ts +++ b/src/api/routes/guilds/#guild_id/webhooks.ts
@@ -33,7 +33,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const webhooks = await Webhook.find({ where: { guild_id }, relations: { user: true, channel: true, source_channel: true, guild: true, source_guild: true, application: true }, diff --git a/src/api/routes/guilds/#guild_id/welcome-screen.ts b/src/api/routes/guilds/#guild_id/welcome-screen.ts
index 474d5977..dee7fb45 100644 --- a/src/api/routes/guilds/#guild_id/welcome-screen.ts +++ b/src/api/routes/guilds/#guild_id/welcome-screen.ts
@@ -36,7 +36,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const guild_id = req.params.guild_id; + const guild_id = req.params.guild_id as string; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); await Member.IsInGuildOrFail(req.user_id, guild_id); @@ -61,7 +61,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const guild_id = req.params.guild_id; + const guild_id = req.params.guild_id as string; const body = req.body as GuildUpdateWelcomeScreenSchema; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); diff --git a/src/api/routes/guilds/#guild_id/widget.json.ts b/src/api/routes/guilds/#guild_id/widget.json.ts
index 6827c7f6..945a0db0 100644 --- a/src/api/routes/guilds/#guild_id/widget.json.ts +++ b/src/api/routes/guilds/#guild_id/widget.json.ts
@@ -47,7 +47,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; let cacheEntry = jsonDataCache.get(guild_id); if (!cacheEntry || cacheEntry.expiry.getTime() < Date.now()) { diff --git a/src/api/routes/guilds/#guild_id/widget.png.ts b/src/api/routes/guilds/#guild_id/widget.png.ts
index 3ff95e99..c1382c90 100644 --- a/src/api/routes/guilds/#guild_id/widget.png.ts +++ b/src/api/routes/guilds/#guild_id/widget.png.ts
@@ -46,7 +46,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); if (!guild.widget_enabled) throw DiscordApiErrors.EMBED_DISABLED; diff --git a/src/api/routes/guilds/#guild_id/widget.ts b/src/api/routes/guilds/#guild_id/widget.ts
index 5a2fdb96..122789dc 100644 --- a/src/api/routes/guilds/#guild_id/widget.ts +++ b/src/api/routes/guilds/#guild_id/widget.ts
@@ -37,7 +37,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id } }); @@ -68,7 +68,7 @@ router.patch( }), async (req: Request, res: Response) => { const body = req.body as WidgetModifySchema; - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; await Guild.update( { id: guild_id }, diff --git a/src/api/routes/guilds/templates/index.ts b/src/api/routes/guilds/templates/index.ts
index 51d2fd3b..391f9c8a 100644 --- a/src/api/routes/guilds/templates/index.ts +++ b/src/api/routes/guilds/templates/index.ts
@@ -40,7 +40,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { template_code } = req.params; + const { template_code } = req.params as { [key: string]: string }; const template = await getTemplate(template_code); @@ -49,7 +49,7 @@ router.get( ); router.post("/:template_code", route({ requestBody: "GuildTemplateCreateSchema" }), async (req: Request, res: Response) => { - const { template_code } = req.params; + const { template_code } = req.params as { [key: string]: string }; const body = req.body as GuildTemplateCreateSchema; const { maxGuilds } = Config.get().limits.user; diff --git a/src/api/routes/interactions/#interaction_id/#interaction_token/callback.ts b/src/api/routes/interactions/#interaction_id/#interaction_token/callback.ts
index e94d455a..3734a12e 100644 --- a/src/api/routes/interactions/#interaction_id/#interaction_token/callback.ts +++ b/src/api/routes/interactions/#interaction_id/#interaction_token/callback.ts
@@ -68,7 +68,7 @@ router.post("/", route({}), async (req: Request, res: Response) => { throw FieldErrors(errors); } - const interactionId = req.params.interaction_id; + const interactionId = req.params.interaction_id as string; const interaction = pendingInteractions.get(req.params.interaction_id); if (!interaction) { diff --git a/src/api/routes/invites/index.ts b/src/api/routes/invites/index.ts
index 630fe03c..316e7686 100644 --- a/src/api/routes/invites/index.ts +++ b/src/api/routes/invites/index.ts
@@ -37,7 +37,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { invite_code } = req.params; + const { invite_code } = req.params as { [key: string]: string }; const invite = await Invite.findOneOrFail({ where: { code: invite_code }, @@ -70,7 +70,7 @@ router.post( async (req: Request, res: Response) => { if (req.user_bot && !Config.get().user.botsCanUseInvites) throw DiscordApiErrors.BOT_PROHIBITED_ENDPOINT; - const { invite_code } = req.params; + const { invite_code } = req.params as { [key: string]: string }; const { public_flags } = req.user; const { guild_id } = await Invite.findOneOrFail({ where: { code: invite_code }, @@ -128,7 +128,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { invite_code } = req.params; + const { invite_code } = req.params as { [key: string]: string }; const invite = await Invite.findOneOrFail({ where: { code: invite_code } }); const { guild_id, channel_id } = invite; diff --git a/src/api/routes/oauth2/applications/@me.ts b/src/api/routes/oauth2/applications/@me.ts
index e750a62a..c8aa84f6 100644 --- a/src/api/routes/oauth2/applications/@me.ts +++ b/src/api/routes/oauth2/applications/@me.ts
@@ -34,7 +34,7 @@ router.get( }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.id }, // ...huh? there's no ID in the path... + where: { id: req.params.id as string }, // ...huh? there's no ID in the path... relations: { bot: true, owner: true }, select: { owner: Object.fromEntries(PublicUserProjection.map((x) => [x, true])), diff --git a/src/api/routes/partners/#guild_id/requirements.ts b/src/api/routes/partners/#guild_id/requirements.ts
index 3f0e48c6..7592d236 100644 --- a/src/api/routes/partners/#guild_id/requirements.ts +++ b/src/api/routes/partners/#guild_id/requirements.ts
@@ -22,7 +22,7 @@ import { route } from "@spacebar/api"; const router = Router({ mergeParams: true }); router.get("/", route({}), (req: Request, res: Response) => { - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; // TODO: // Load from database // Admin control, but for now it allows anyone to be discoverable diff --git a/src/api/routes/stickers/#sticker_id/index.ts b/src/api/routes/stickers/#sticker_id/index.ts
index 0f850efd..ddfbbe4c 100644 --- a/src/api/routes/stickers/#sticker_id/index.ts +++ b/src/api/routes/stickers/#sticker_id/index.ts
@@ -31,7 +31,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { sticker_id } = req.params; + const { sticker_id } = req.params as { [key: string]: string }; res.json(await Sticker.find({ where: { id: sticker_id } })); }, diff --git a/src/api/routes/store/published-listings/skus/#sku_id/subscription-plans.ts b/src/api/routes/store/published-listings/skus/#sku_id/subscription-plans.ts
index 2c9ad4e0..13db49d6 100644 --- a/src/api/routes/store/published-listings/skus/#sku_id/subscription-plans.ts +++ b/src/api/routes/store/published-listings/skus/#sku_id/subscription-plans.ts
@@ -318,7 +318,7 @@ const skus = new Map([ router.get("/", route({}), (req: Request, res: Response) => { // TODO: add the ability to add custom - const { sku_id } = req.params; + const { sku_id } = req.params as { [key: string]: string }; if (!skus.has(sku_id)) { console.log(`Request for invalid SKU ${sku_id}! Please report this!`); diff --git a/src/api/routes/users/#user_id/delete.ts b/src/api/routes/users/#user_id/delete.ts
index 598be974..a0730cb7 100644 --- a/src/api/routes/users/#user_id/delete.ts +++ b/src/api/routes/users/#user_id/delete.ts
@@ -58,7 +58,7 @@ router.post( const sw = Stopwatch.startNew(); const body = req.body as InstanceUserDeleteSchema | undefined; const user = await User.findOneOrFail({ - where: { id: req.params.user_id }, + where: { id: req.params.user_id as string }, select: [...PrivateUserProjection, "data"], }); @@ -130,11 +130,11 @@ router.post( ); // change ownership on guilds - const guilds = await Guild.find({ where: { owner_id: req.params.user_id } }); + const guilds = await Guild.find({ where: { owner_id: req.params.user_id as string } }); await Promise.all( guilds.map(async (guild) => { const members = await Member.find({ - where: { guild_id: guild.id, id: Not(req.params.user_id) }, + where: { guild_id: guild.id, id: Not(req.params.user_id as string) }, relations: { roles: true }, select: { id: true, roles: { id: true, position: true } }, }); @@ -156,7 +156,7 @@ router.post( console.log(`[Instance ban] Transferred ownership of guild ${guild.id} to user ${guild.owner_id}`); // safety - reassign emojis/stickers owned by the old owner - const stickers = await Sticker.find({ where: { guild_id: guild.id, user_id: req.params.user_id } }); + const stickers = await Sticker.find({ where: { guild_id: guild.id, user_id: req.params.user_id as string } }); await Promise.all( stickers.map(async (sticker) => { sticker.user_id = guild.owner_id; @@ -165,7 +165,7 @@ router.post( }), ); - const emojis = await Emoji.find({ where: { guild_id: guild.id, user_id: req.params.user_id } }); + const emojis = await Emoji.find({ where: { guild_id: guild.id, user_id: req.params.user_id as string } }); await Promise.all( emojis.map(async (emoji) => { emoji.user_id = guild.owner_id!; @@ -177,16 +177,16 @@ router.post( }), ); - const members = await Member.find({ where: { id: req.params.user_id } }); + const members = await Member.find({ where: { id: req.params.user_id as string } }); await Promise.all([...members.map((member) => Member.removeFromGuild(member.id, member.guild_id))]); - await UserSettingsProtos.delete({ user_id: req.params.user_id }); - await User.delete({ id: req.params.user_id }); + await UserSettingsProtos.delete({ user_id: req.params.user_id as string }); + await User.delete({ id: req.params.user_id as string }); // TODO: respect intents as USER_DELETE has potential to cause privacy issues await emitEvent({ event: "USER_DELETE", user_id: req.user_id, - data: { user_id: req.params.user_id }, + data: { user_id: req.params.user_id as string }, } as UserDeleteEvent); console.log(`[Instance ban] Deleted user ${user.id} from instance in ${sw.elapsed().toString()}`); diff --git a/src/api/routes/users/#user_id/index.ts b/src/api/routes/users/#user_id/index.ts
index 7fca1e0e..ada0e916 100644 --- a/src/api/routes/users/#user_id/index.ts +++ b/src/api/routes/users/#user_id/index.ts
@@ -32,7 +32,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; res.json(await User.getPublicUser(user_id)); }, diff --git a/src/api/routes/users/#user_id/messages.ts b/src/api/routes/users/#user_id/messages.ts
index 95c7cfc4..5d86c282 100644 --- a/src/api/routes/users/#user_id/messages.ts +++ b/src/api/routes/users/#user_id/messages.ts
@@ -35,7 +35,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const user = await User.findOneOrFail({ where: { id: req.params.user_id } }); + const user = await User.findOneOrFail({ where: { id: req.params.user_id as string } }); const channel = await user.getDmChannelWith(req.user_id); const messages = ( diff --git a/src/api/routes/users/#user_id/profile.ts b/src/api/routes/users/#user_id/profile.ts
index c7996c07..fccdeca3 100644 --- a/src/api/routes/users/#user_id/profile.ts +++ b/src/api/routes/users/#user_id/profile.ts
@@ -28,7 +28,7 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), if (req.params.user_id === "@me") req.params.user_id = req.user_id; const { guild_id, with_mutual_guilds, with_mutual_friends, with_mutual_friends_count } = req.query; - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; const user = await User.findOneOrFail({ where: { diff --git a/src/api/routes/users/#user_id/relationships.ts b/src/api/routes/users/#user_id/relationships.ts
index 93f11296..38bd64b6 100644 --- a/src/api/routes/users/#user_id/relationships.ts +++ b/src/api/routes/users/#user_id/relationships.ts
@@ -37,7 +37,7 @@ router.get( const mutual_relations: UserRelationsResponse = []; const requested_relations = await User.findOneOrFail({ - where: { id: req.params.user_id }, + where: { id: req.params.user_id as string }, relations: { relationships: true }, }); const self_relations = await User.findOneOrFail({ 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 a85348ae..6e6d7e2f 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
@@ -28,7 +28,7 @@ const ALLOWED_CONNECTIONS = ["twitch", "youtube"]; // NOTE: this route has not been extensively tested, as the required connections are not implemented as of writing router.get("/", route({}), async (req: Request, res: Response) => { - const { connection_name, connection_id } = req.params; + const { connection_name, connection_id } = req.params as { [key: string]: string }; const connection = ConnectionStore.connections.get(connection_name); 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 718c80c0..0fc6f3fb 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
@@ -24,7 +24,7 @@ const router = Router({ mergeParams: true }); // TODO: connection update schema router.patch("/", route({ requestBody: "ConnectionUpdateSchema" }), async (req: Request, res: Response) => { - const { connection_name, connection_id } = req.params; + const { connection_name, connection_id } = req.params as { [key: string]: string }; const body = req.body as ConnectionUpdateSchema; const connection = await ConnectedAccount.findOne({ @@ -63,7 +63,7 @@ router.patch("/", route({ requestBody: "ConnectionUpdateSchema" }), async (req: }); router.delete("/", route({}), async (req: Request, res: Response) => { - const { connection_name, connection_id } = req.params; + const { connection_name, connection_id } = req.params as { [key: string]: string }; const account = await ConnectedAccount.findOneOrFail({ where: { diff --git a/src/api/routes/users/@me/guilds.ts b/src/api/routes/users/@me/guilds.ts
index 8fcec95a..d2740678 100644 --- a/src/api/routes/users/@me/guilds.ts +++ b/src/api/routes/users/@me/guilds.ts
@@ -64,7 +64,7 @@ router.delete( }), async (req: Request, res: Response) => { const { autoJoin } = Config.get().guild; - const { guild_id } = req.params; + const { guild_id } = req.params as { [key: string]: string }; const guild = await Guild.findOneOrFail({ where: { id: guild_id }, select: { owner_id: true }, 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 3aaf723e..1501ac4b 100644 --- a/src/api/routes/users/@me/guilds/#guild_id/settings.ts +++ b/src/api/routes/users/@me/guilds/#guild_id/settings.ts
@@ -34,7 +34,7 @@ router.get( }), async (req: Request, res: Response) => { const user = await Member.findOneOrFail({ - where: { id: req.user_id, guild_id: req.params.guild_id }, + where: { id: req.user_id, guild_id: req.params.guild_id as string }, select: { settings: true }, }); return res.json(user.settings); @@ -65,11 +65,11 @@ router.patch( } const user = await Member.findOneOrFail({ - where: { id: req.user_id, guild_id: req.params.guild_id }, + where: { id: req.user_id, guild_id: req.params.guild_id as string }, select: { settings: true }, }); OrmUtils.mergeDeep(user.settings || {}, body); - Member.update({ id: req.user_id, guild_id: req.params.guild_id }, user); + Member.update({ id: req.user_id, guild_id: req.params.guild_id as string }, user); res.json(user.settings); }, diff --git a/src/api/routes/users/@me/mfa/webauthn/credentials/#key_id/index.ts b/src/api/routes/users/@me/mfa/webauthn/credentials/#key_id/index.ts
index 77180cac..65c01806 100644 --- a/src/api/routes/users/@me/mfa/webauthn/credentials/#key_id/index.ts +++ b/src/api/routes/users/@me/mfa/webauthn/credentials/#key_id/index.ts
@@ -29,7 +29,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { key_id } = req.params; + const { key_id } = req.params as { [key: string]: string }; await SecurityKey.delete({ id: key_id, diff --git a/src/api/routes/users/@me/notes.ts b/src/api/routes/users/@me/notes.ts
index f25aca79..0b174791 100644 --- a/src/api/routes/users/@me/notes.ts +++ b/src/api/routes/users/@me/notes.ts
@@ -35,7 +35,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; const note = await Note.findOneOrFail({ where: { @@ -64,7 +64,7 @@ router.put( }, }), async (req: Request, res: Response) => { - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; const owner = req.user; const target = await User.findOneOrFail({ where: { id: user_id } }); //if noted user does not exist throw const { note } = req.body; diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts
index 37d5e222..88f95a3d 100644 --- a/src/api/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts
@@ -69,7 +69,7 @@ router.put( req, res, await User.findOneOrFail({ - where: { id: req.params.user_id }, + where: { id: req.params.user_id as string }, relations: { relationships: { to: true } }, select: userProjection, }), @@ -97,7 +97,7 @@ router.patch( const rel = await Relationship.findOneOrFail({ where: { from_id: req.user_id, - to_id: req.params.user_id, + to_id: req.params.user_id as string, }, }); rel.nickname = body.nickname; @@ -161,7 +161,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { user_id } = req.params; + const { user_id } = req.params as { [key: string]: string }; if (user_id === req.user_id) throw new HTTPError("You can't remove yourself as a friend"); const user = await User.findOneOrFail({ diff --git a/src/api/routes/webhooks/#webhook_id/#token/index.ts b/src/api/routes/webhooks/#webhook_id/#token/index.ts
index 7bb1cd9f..556ee489 100644 --- a/src/api/routes/webhooks/#webhook_id/#token/index.ts +++ b/src/api/routes/webhooks/#webhook_id/#token/index.ts
@@ -19,7 +19,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { webhook_id, token } = req.params; + const { webhook_id, token } = req.params as { [key: string]: string }; const webhook = await Webhook.findOne({ where: { id: webhook_id, @@ -101,7 +101,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { webhook_id, token } = req.params; + const { webhook_id, token } = req.params as { [key: string]: string }; const webhook = await Webhook.findOne({ where: { @@ -149,7 +149,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { webhook_id, token } = req.params; + const { webhook_id, token } = req.params as { [key: string]: string }; const body = req.body as WebhookUpdateSchema; const webhook = await Webhook.findOneOrFail({ diff --git a/src/api/routes/webhooks/#webhook_id/index.ts b/src/api/routes/webhooks/#webhook_id/index.ts
index bf275fb5..2282a460 100644 --- a/src/api/routes/webhooks/#webhook_id/index.ts +++ b/src/api/routes/webhooks/#webhook_id/index.ts
@@ -17,7 +17,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const { webhook_id } = req.params; + const { webhook_id } = req.params as { [key: string]: string }; const webhook = await Webhook.findOneOrFail({ where: { id: webhook_id }, relations: { user: true, channel: true, source_channel: true, guild: true, source_guild: true, application: true }, @@ -48,7 +48,7 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { webhook_id } = req.params; + const { webhook_id } = req.params as { [key: string]: string }; const webhook = await Webhook.findOneOrFail({ where: { id: webhook_id }, @@ -93,7 +93,7 @@ router.patch( }, }), async (req: Request, res: Response) => { - const { webhook_id } = req.params; + const { webhook_id } = req.params as { [key: string]: string }; const body = req.body as WebhookUpdateSchema; const webhook = await Webhook.findOneOrFail({ diff --git a/src/api/util/handlers/Webhook.ts b/src/api/util/handlers/Webhook.ts
index d4aceb89..fe144171 100644 --- a/src/api/util/handlers/Webhook.ts +++ b/src/api/util/handlers/Webhook.ts
@@ -8,7 +8,7 @@ import { WebhookExecuteSchema } from "@spacebar/schemas"; export const executeWebhook = async (req: Request, res: Response) => { const body = req.body as WebhookExecuteSchema; - const { webhook_id, token } = req.params; + const { webhook_id, token } = req.params as { [key: string]: string }; const webhook = await Webhook.findOne({ where: { diff --git a/src/api/util/handlers/route.ts b/src/api/util/handlers/route.ts
index 022a522a..43aab155 100644 --- a/src/api/util/handlers/route.ts +++ b/src/api/util/handlers/route.ts
@@ -89,7 +89,8 @@ export function route(opts: RouteOptions) { return async (req: Request, res: Response, next: NextFunction) => { if (opts.permission) { - req.permission = await getPermission(req.user_id, req.params.guild_id, req.params.channel_id); + const { guild_id, channel_id } = req.params as { [key: string]: string }; + req.permission = await getPermission(req.user_id, guild_id, channel_id); const requiredPerms = Array.isArray(opts.permission) ? opts.permission : [opts.permission]; requiredPerms.forEach((perm) => {