| 274 | } |
| 275 | |
| 276 | export async function getClient( |
| 277 | request: FastifyRequest<{ Params: { id: string } }>, |
| 278 | reply: FastifyReply |
| 279 | ) { |
| 280 | const client = await db.client.findFirst({ |
| 281 | where: { |
| 282 | id: request.params.id, |
| 283 | organizationId: request.client!.organizationId, |
| 284 | }, |
| 285 | }); |
| 286 | |
| 287 | if (!client) { |
| 288 | throw new HttpError('Client not found', { status: 404 }); |
| 289 | } |
| 290 | |
| 291 | reply.send({ data: client }); |
| 292 | } |
| 293 | |
| 294 | export async function createClient( |
| 295 | request: FastifyRequest<{ Body: z.infer<typeof zCreateClient> }>, |