| 371 | } |
| 372 | |
| 373 | export async function deleteClient( |
| 374 | request: FastifyRequest<{ Params: { id: string } }>, |
| 375 | reply: FastifyReply |
| 376 | ) { |
| 377 | const client = await db.client.findFirst({ |
| 378 | where: { |
| 379 | id: request.params.id, |
| 380 | organizationId: request.client!.organizationId, |
| 381 | }, |
| 382 | }); |
| 383 | |
| 384 | if (!client) { |
| 385 | throw new HttpError('Client not found', { status: 404 }); |
| 386 | } |
| 387 | |
| 388 | await db.client.delete({ |
| 389 | where: { |
| 390 | id: request.params.id, |
| 391 | }, |
| 392 | }); |
| 393 | |
| 394 | await getClientByIdCached.clear(request.params.id); |
| 395 | |
| 396 | reply.send({ success: true }); |
| 397 | } |
| 398 | |
| 399 | // References CRUD |
| 400 | export async function listReferences( |