From e8c5c988bb9d0c41de46b2029eefe4faa7e0e068 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sat, 11 Oct 2025 03:58:37 +0200 Subject: [PATCH] Update path variables --- assets/openapi.json | Bin 1492268 -> 1512590 bytes .../{#id => #application_id}/bot/index.ts | 6 ++--- .../{#id => #application_id}/entitlements.ts | 0 .../{#id => #application_id}/index.ts | 6 ++--- .../{#id => #application_id}/skus.ts | 0 src/api/routes/guilds/templates/index.ts | 12 ++++----- src/api/routes/invites/index.ts | 24 +++++++++--------- .../store/published-listings/applications.ts | 2 +- .../routes/store/published-listings/skus.ts | 2 +- .../routes/users/{#id => #user_id}/delete.ts | 8 +++--- .../routes/users/{#id => #user_id}/index.ts | 4 +-- .../users/{#id => #user_id}/messages.ts | 2 +- .../routes/users/{#id => #user_id}/profile.ts | 10 ++++---- .../users/{#id => #user_id}/relationships.ts | 2 +- 14 files changed, 39 insertions(+), 39 deletions(-) rename src/api/routes/applications/{#id => #application_id}/bot/index.ts (96%) rename src/api/routes/applications/{#id => #application_id}/entitlements.ts (100%) rename src/api/routes/applications/{#id => #application_id}/index.ts (96%) rename src/api/routes/applications/{#id => #application_id}/skus.ts (100%) rename src/api/routes/users/{#id => #user_id}/delete.ts (90%) rename src/api/routes/users/{#id => #user_id}/index.ts (93%) rename src/api/routes/users/{#id => #user_id}/messages.ts (99%) rename src/api/routes/users/{#id => #user_id}/profile.ts (94%) rename src/api/routes/users/{#id => #user_id}/relationships.ts (98%) diff --git a/assets/openapi.json b/assets/openapi.json index 80f7881829487f5d5abcb326d8b3aa91ff13b3ba..7407a75a0d90860ead6650ee707e1f902d925f8e 100644 GIT binary patch delta 1170 zcmb7BO-NKx6y`ebjX!T3=bblmD>W*^ASg#I3la5hVG>eNy zLKzyWjb~^PO`>Zr9%( zIvW*CqzQ|Vge*Zi1;6v|6C??M8FSd@ham1$W!T@T{ogA@lcu>rvi$BifrIRjzW(fa*)i3s~nq$ z!=+he8xB6@35qVO(+n?^LW?O&zS%O+8VN>1GG_*zB?E!olw>e2)Pl>4nHMG*l%SwI$Pc6k1 delta 344 zcmeBM8MCGGTEMBImXnFp0Y|PB-WlvY-CFR!Dh!dZSPhGk!&4(|5NB@ohKj z5YmvJwnRv6yVVLIG2`ic--QgeI~*01W}I%z&Z{upAx}(c`hq-m`RxI>L { const app = await Application.findOneOrFail({ - where: { id: req.params.id }, + where: { id: req.params.application_id }, relations: ["owner"], }); @@ -74,7 +74,7 @@ router.post( }, }), async (req: Request, res: Response) => { - const bot = await User.findOneOrFail({ where: { id: req.params.id } }); + const bot = await User.findOneOrFail({ where: { id: req.params.application_id } }); const owner = await User.findOneOrFail({ where: { id: req.user_id } }); if (owner.id != req.user_id) @@ -114,7 +114,7 @@ router.patch( if (!body.avatar?.trim()) delete body.avatar; const app = await Application.findOneOrFail({ - where: { id: req.params.id }, + where: { id: req.params.application_id }, relations: ["bot", "owner"], }); diff --git a/src/api/routes/applications/#id/entitlements.ts b/src/api/routes/applications/#application_id/entitlements.ts similarity index 100% rename from src/api/routes/applications/#id/entitlements.ts rename to src/api/routes/applications/#application_id/entitlements.ts diff --git a/src/api/routes/applications/#id/index.ts b/src/api/routes/applications/#application_id/index.ts similarity index 96% rename from src/api/routes/applications/#id/index.ts rename to src/api/routes/applications/#application_id/index.ts index efb9ecdd..d6ba26fe 100644 --- a/src/api/routes/applications/#id/index.ts +++ b/src/api/routes/applications/#application_id/index.ts @@ -44,7 +44,7 @@ router.get( }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.id }, + where: { id: req.params.application_id }, relations: ["owner", "bot"], }); if (app.owner.id != req.user_id) @@ -71,7 +71,7 @@ router.patch( const body = req.body as ApplicationModifySchema; const app = await Application.findOneOrFail({ - where: { id: req.params.id }, + where: { id: req.params.application_id }, relations: ["owner", "bot"], }); @@ -135,7 +135,7 @@ router.post( }), async (req: Request, res: Response) => { const app = await Application.findOneOrFail({ - where: { id: req.params.id }, + where: { id: req.params.application_id }, relations: ["bot", "owner"], }); if (app.owner.id != req.user_id) diff --git a/src/api/routes/applications/#id/skus.ts b/src/api/routes/applications/#application_id/skus.ts similarity index 100% rename from src/api/routes/applications/#id/skus.ts rename to src/api/routes/applications/#application_id/skus.ts diff --git a/src/api/routes/guilds/templates/index.ts b/src/api/routes/guilds/templates/index.ts index e4a959f8..002347d3 100644 --- a/src/api/routes/guilds/templates/index.ts +++ b/src/api/routes/guilds/templates/index.ts @@ -25,7 +25,7 @@ import { HTTPError } from "lambert-server"; const router: Router = Router({ mergeParams: true }); router.get( - "/:code", + "/:template_code", route({ responses: { 200: { @@ -40,16 +40,16 @@ router.get( }, }), async (req: Request, res: Response) => { - const { code } = req.params; + const { template_code } = req.params; - const template = await getTemplate(code); + const template = await getTemplate(template_code); res.json(template); }, ); -router.post("/:code", route({ requestBody: "GuildTemplateCreateSchema" }), async (req: Request, res: Response) => { - const { code } = req.params; +router.post("/:template_code", route({ requestBody: "GuildTemplateCreateSchema" }), async (req: Request, res: Response) => { + const { template_code } = req.params; const body = req.body as GuildTemplateCreateSchema; const { maxGuilds } = Config.get().limits.user; @@ -57,7 +57,7 @@ router.post("/:code", route({ requestBody: "GuildTemplateCreateSchema" }), async const guild_count = await Member.count({ where: { id: req.user_id } }); if (guild_count >= maxGuilds) throw DiscordApiErrors.MAXIMUM_GUILDS.withParams(maxGuilds); - const template = await getTemplate(code) as Template; + const template = await getTemplate(template_code) as Template; const guild = await Guild.createGuild({ ...template.serialized_source_guild, diff --git a/src/api/routes/invites/index.ts b/src/api/routes/invites/index.ts index 22191881..b807fe21 100644 --- a/src/api/routes/invites/index.ts +++ b/src/api/routes/invites/index.ts @@ -33,7 +33,7 @@ import { HTTPError } from "lambert-server"; const router: Router = Router({ mergeParams: true }); router.get( - "/:code", + "/:invite_code", route({ responses: { "200": { @@ -45,10 +45,10 @@ router.get( }, }), async (req: Request, res: Response) => { - const { code } = req.params; + const { invite_code } = req.params; const invite = await Invite.findOneOrFail({ - where: { code }, + where: { code: invite_code }, relations: PublicInviteRelation, }); @@ -57,7 +57,7 @@ router.get( ); router.post( - "/:code", + "/:invite_code", route({ right: "USE_MASS_INVITES", responses: { @@ -78,9 +78,9 @@ router.post( async (req: Request, res: Response) => { if (req.user_bot) throw DiscordApiErrors.BOT_PROHIBITED_ENDPOINT; - const { code } = req.params; + const { invite_code } = req.params; const { guild_id } = await Invite.findOneOrFail({ - where: { code: code }, + where: { code: invite_code }, }); const { features } = await Guild.findOneOrFail({ where: { id: guild_id }, @@ -100,7 +100,7 @@ router.post( if (features.includes("INVITES_DISABLED")) throw new HTTPError("Sorry, this guild has joins closed.", 403); - const invite = await Invite.joinGuild(req.user_id, code); + const invite = await Invite.joinGuild(req.user_id, invite_code); res.json(invite); }, @@ -108,7 +108,7 @@ router.post( // * cant use permission of route() function because path doesn't have guild_id/channel_id router.delete( - "/:code", + "/:invite_code", route({ responses: { "200": { @@ -123,8 +123,8 @@ router.delete( }, }), async (req: Request, res: Response) => { - const { code } = req.params; - const invite = await Invite.findOneOrFail({ where: { code } }); + const { invite_code } = req.params; + const invite = await Invite.findOneOrFail({ where: { code: invite_code } }); const { guild_id, channel_id } = invite; const permission = await getPermission( @@ -143,14 +143,14 @@ router.delete( ); await Promise.all([ - Invite.delete({ code }), + Invite.delete({ code: invite_code }), emitEvent({ event: "INVITE_DELETE", guild_id: guild_id, data: { channel_id: channel_id, guild_id: guild_id, - code: code, + code: invite_code, }, } as InviteDeleteEvent), ]); diff --git a/src/api/routes/store/published-listings/applications.ts b/src/api/routes/store/published-listings/applications.ts index 1881d657..b5cabb93 100644 --- a/src/api/routes/store/published-listings/applications.ts +++ b/src/api/routes/store/published-listings/applications.ts @@ -21,7 +21,7 @@ import { route } from "@spacebar/api"; const router: Router = Router({ mergeParams: true }); -router.get("/:id", route({}), async (req: Request, res: Response) => { +router.get("/:application_id", route({}), async (req: Request, res: Response) => { //TODO // const id = req.params.id; res.json({ diff --git a/src/api/routes/store/published-listings/skus.ts b/src/api/routes/store/published-listings/skus.ts index 1881d657..a463b4e4 100644 --- a/src/api/routes/store/published-listings/skus.ts +++ b/src/api/routes/store/published-listings/skus.ts @@ -21,7 +21,7 @@ import { route } from "@spacebar/api"; const router: Router = Router({ mergeParams: true }); -router.get("/:id", route({}), async (req: Request, res: Response) => { +router.get("/:sku_id", route({}), async (req: Request, res: Response) => { //TODO // const id = req.params.id; res.json({ diff --git a/src/api/routes/users/#id/delete.ts b/src/api/routes/users/#user_id/delete.ts similarity index 90% rename from src/api/routes/users/#id/delete.ts rename to src/api/routes/users/#user_id/delete.ts index 4c7747c9..53af01eb 100644 --- a/src/api/routes/users/#id/delete.ts +++ b/src/api/routes/users/#user_id/delete.ts @@ -44,19 +44,19 @@ router.post( }), async (req: Request, res: Response) => { await User.findOneOrFail({ - where: { id: req.params.id }, + where: { id: req.params.user_id }, select: [...PrivateUserProjection, "data"], }); await Promise.all([ - Member.delete({ id: req.params.id }), - User.delete({ id: req.params.id }), + Member.delete({ id: req.params.user_id }), + User.delete({ id: req.params.user_id }), ]); // 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.id }, + data: { user_id: req.params.user_id }, } as UserDeleteEvent); res.sendStatus(204); diff --git a/src/api/routes/users/#id/index.ts b/src/api/routes/users/#user_id/index.ts similarity index 93% rename from src/api/routes/users/#id/index.ts rename to src/api/routes/users/#user_id/index.ts index 882fa2b7..417f961d 100644 --- a/src/api/routes/users/#id/index.ts +++ b/src/api/routes/users/#user_id/index.ts @@ -32,9 +32,9 @@ router.get( }, }), async (req: Request, res: Response) => { - const { id } = req.params; + const { user_id } = req.params; - res.json(await User.getPublicUser(id)); + res.json(await User.getPublicUser(user_id)); }, ); diff --git a/src/api/routes/users/#id/messages.ts b/src/api/routes/users/#user_id/messages.ts similarity index 99% rename from src/api/routes/users/#id/messages.ts rename to src/api/routes/users/#user_id/messages.ts index 4d724575..04708cfd 100644 --- a/src/api/routes/users/#id/messages.ts +++ b/src/api/routes/users/#user_id/messages.ts @@ -34,7 +34,7 @@ router.get( }, }), async (req: Request, res: Response) => { - const user = await User.findOneOrFail({ where: { id: req.params.id } }); + const user = await User.findOneOrFail({ where: { id: req.params.user_id } }); const channel = await user.getDmChannelWith(req.user_id); const messages = ( diff --git a/src/api/routes/users/#id/profile.ts b/src/api/routes/users/#user_id/profile.ts similarity index 94% rename from src/api/routes/users/#id/profile.ts rename to src/api/routes/users/#user_id/profile.ts index e2eaa036..30b4fb01 100644 --- a/src/api/routes/users/#id/profile.ts +++ b/src/api/routes/users/#user_id/profile.ts @@ -39,11 +39,11 @@ import { In } from "typeorm"; const router: Router = Router({ mergeParams: true }); router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), async (req: Request, res: Response) => { - if (req.params.id === "@me") req.params.id = req.user_id; + 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 = await User.getPublicUser(req.params.id, { + const user = await User.getPublicUser(req.params.user_id, { relations: ["connected_accounts"], }); @@ -52,7 +52,7 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), if (with_mutual_guilds == "true") { const requested_member = await Member.find({ - where: { id: req.params.id }, + where: { id: req.params.user_id }, }); const self_member = await Member.find({ where: { id: req.user_id }, @@ -82,7 +82,7 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), const guild_member = guild_id && typeof guild_id == "string" ? await Member.findOneOrFail({ - where: { id: req.params.id, guild_id: guild_id }, + where: { id: req.params.user_id, guild_id: guild_id }, relations: ["roles"], }) : undefined; @@ -111,7 +111,7 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), if (with_mutual_friends == "true" || with_mutual_friends_count == "true") { const relationshipsSelf = await Relationship.find({ where: { from_id: req.user_id, type: RelationshipType.friends } }); - const relationshipsUser = await Relationship.find({ where: { from_id: req.params.id, type: RelationshipType.friends } }); + const relationshipsUser = await Relationship.find({ where: { from_id: req.params.user_id, type: RelationshipType.friends } }); const relationshipsIntersection = relationshipsSelf.filter((r1) => relationshipsUser.some((r2) => r2.to_id === r1.to_id)); if (with_mutual_friends_count) mutual_friends_count = relationshipsIntersection.length; if (with_mutual_friends) { diff --git a/src/api/routes/users/#id/relationships.ts b/src/api/routes/users/#user_id/relationships.ts similarity index 98% rename from src/api/routes/users/#id/relationships.ts rename to src/api/routes/users/#user_id/relationships.ts index 4c92c789..e4af351f 100644 --- a/src/api/routes/users/#id/relationships.ts +++ b/src/api/routes/users/#user_id/relationships.ts @@ -36,7 +36,7 @@ router.get( const mutual_relations: UserRelationsResponse = []; const requested_relations = await User.findOneOrFail({ - where: { id: req.params.id }, + where: { id: req.params.user_id }, relations: ["relationships"], }); const self_relations = await User.findOneOrFail({