remove org from get client route

This commit is contained in:
miloschwartz 2025-08-18 12:06:01 -07:00
parent 48963f24df
commit d207318494
No known key found for this signature in database
4 changed files with 12 additions and 13 deletions

View file

@ -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<Awaited<ReturnType<typeof query>>>;
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(

View file

@ -134,9 +134,9 @@ authenticated.get(
);
authenticated.get(
"/org/:orgId/client/:clientId",
"/client/:clientId",
verifyClientsEnabled,
verifyOrgAccess,
verifyClientAccess,
verifyUserHasAction(ActionsEnum.getClient),
client.getClient
);

View file

@ -526,9 +526,9 @@ authenticated.get(
);
authenticated.get(
"/org/:orgId/client/:clientId",
"/client/:clientId",
verifyClientsEnabled,
verifyApiKeyOrgAccess,
verifyApiKeyClientAccess,
verifyApiKeyHasAction(ActionsEnum.getClient),
client.getClient
);

View file

@ -21,7 +21,7 @@ export default async function SettingsLayout(props: SettingsLayoutProps) {
let client = null;
try {
const res = await internal.get<AxiosResponse<GetClientResponse>>(
`/org/${params.orgId}/client/${params.clientId}`,
`/client/${params.clientId}`,
await authCookieHeader()
);
client = res.data.data;