MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / updateClient

Function updateClient

apps/api/src/controllers/manage.controller.ts:337–371  ·  view source on GitHub ↗
(
  request: FastifyRequest<{
    Params: { id: string };
    Body: z.infer<typeof zUpdateClient>;
  }>,
  reply: FastifyReply
)

Source from the content-addressed store, hash-verified

335}
336
337export async function updateClient(
338 request: FastifyRequest<{
339 Params: { id: string };
340 Body: z.infer<typeof zUpdateClient>;
341 }>,
342 reply: FastifyReply
343) {
344 // Verify client exists and belongs to organization
345 const existing = await db.client.findFirst({
346 where: {
347 id: request.params.id,
348 organizationId: request.client!.organizationId,
349 },
350 });
351
352 if (!existing) {
353 throw new HttpError('Client not found', { status: 404 });
354 }
355
356 const updateData: any = {};
357 if (request.body.name !== undefined) {
358 updateData.name = request.body.name;
359 }
360
361 const client = await db.client.update({
362 where: {
363 id: request.params.id,
364 },
365 data: updateData,
366 });
367
368 await getClientByIdCached.clear(client.id);
369
370 reply.send({ data: client });
371}
372
373export async function deleteClient(
374 request: FastifyRequest<{ Params: { id: string } }>,

Callers

nothing calls this directly

Calls 2

clearMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected