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

Function listClients

apps/api/src/controllers/manage.controller.ts:242–274  ·  view source on GitHub ↗
(
  request: FastifyRequest<{ Querystring: { projectId?: string } }>,
  reply: FastifyReply
)

Source from the content-addressed store, hash-verified

240
241// Clients CRUD
242export async function listClients(
243 request: FastifyRequest<{ Querystring: { projectId?: string } }>,
244 reply: FastifyReply
245) {
246 const where: any = {
247 organizationId: request.client!.organizationId,
248 };
249
250 if (request.query.projectId) {
251 // Verify project belongs to organization
252 const project = await db.project.findFirst({
253 where: {
254 id: request.query.projectId,
255 organizationId: request.client!.organizationId,
256 },
257 });
258
259 if (!project) {
260 throw new HttpError('Project not found', { status: 404 });
261 }
262
263 where.projectId = request.query.projectId;
264 }
265
266 const clients = await db.client.findMany({
267 where,
268 orderBy: {
269 createdAt: 'desc',
270 },
271 });
272
273 reply.send({ data: clients });
274}
275
276export async function getClient(
277 request: FastifyRequest<{ Params: { id: string } }>,

Callers

nothing calls this directly

Calls 1

sendMethod · 0.45

Tested by

no test coverage detected