From d2073184947664b6d25c49277210d881e210adb2 Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Mon, 18 Aug 2025 12:06:01 -0700 Subject: [PATCH] remove org from get client route --- server/routers/client/getClient.ts | 15 +++++++-------- server/routers/external.ts | 4 ++-- server/routers/integration.ts | 4 ++-- .../settings/clients/[clientId]/layout.tsx | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/server/routers/client/getClient.ts b/server/routers/client/getClient.ts index 8f01e87d..d362526f 100644 --- a/server/routers/client/getClient.ts +++ b/server/routers/client/getClient.ts @@ -13,17 +13,16 @@ import { OpenAPITags, registry } from "@server/openApi"; const getClientSchema = z .object({ - clientId: z.string().transform(stoi).pipe(z.number().int().positive()), - orgId: z.string() + clientId: z.string().transform(stoi).pipe(z.number().int().positive()) }) .strict(); -async function query(clientId: number, orgId: string) { +async function query(clientId: number) { // Get the client const [client] = await db .select() .from(clients) - .where(and(eq(clients.clientId, clientId), eq(clients.orgId, orgId))) + .where(and(eq(clients.clientId, clientId))) .limit(1); if (!client) { @@ -47,9 +46,9 @@ export type GetClientResponse = NonNullable>>; registry.registerPath({ method: "get", - path: "/org/{orgId}/client/{clientId}", + path: "/client/{clientId}", description: "Get a client by its client ID.", - tags: [OpenAPITags.Client, OpenAPITags.Org], + tags: [OpenAPITags.Client], request: { params: getClientSchema }, @@ -75,9 +74,9 @@ export async function getClient( ); } - const { clientId, orgId } = parsedParams.data; + const { clientId } = parsedParams.data; - const client = await query(clientId, orgId); + const client = await query(clientId); if (!client) { return next( diff --git a/server/routers/external.ts b/server/routers/external.ts index 65dc6108..9d1de051 100644 --- a/server/routers/external.ts +++ b/server/routers/external.ts @@ -134,9 +134,9 @@ authenticated.get( ); authenticated.get( - "/org/:orgId/client/:clientId", + "/client/:clientId", verifyClientsEnabled, - verifyOrgAccess, + verifyClientAccess, verifyUserHasAction(ActionsEnum.getClient), client.getClient ); diff --git a/server/routers/integration.ts b/server/routers/integration.ts index ee707333..d2734fd3 100644 --- a/server/routers/integration.ts +++ b/server/routers/integration.ts @@ -526,9 +526,9 @@ authenticated.get( ); authenticated.get( - "/org/:orgId/client/:clientId", + "/client/:clientId", verifyClientsEnabled, - verifyApiKeyOrgAccess, + verifyApiKeyClientAccess, verifyApiKeyHasAction(ActionsEnum.getClient), client.getClient ); diff --git a/src/app/[orgId]/settings/clients/[clientId]/layout.tsx b/src/app/[orgId]/settings/clients/[clientId]/layout.tsx index 804162a2..d137b00c 100644 --- a/src/app/[orgId]/settings/clients/[clientId]/layout.tsx +++ b/src/app/[orgId]/settings/clients/[clientId]/layout.tsx @@ -21,7 +21,7 @@ export default async function SettingsLayout(props: SettingsLayoutProps) { let client = null; try { const res = await internal.get>( - `/org/${params.orgId}/client/${params.clientId}`, + `/client/${params.clientId}`, await authCookieHeader() ); client = res.data.data;