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

Function listReferences

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

Source from the content-addressed store, hash-verified

398
399// References CRUD
400export async function listReferences(
401 request: FastifyRequest<{ Querystring: { projectId?: string } }>,
402 reply: FastifyReply
403) {
404 const where: any = {};
405
406 if (request.query.projectId) {
407 // Verify project belongs to organization
408 const project = await db.project.findFirst({
409 where: {
410 id: request.query.projectId,
411 organizationId: request.client!.organizationId,
412 },
413 });
414
415 if (!project) {
416 throw new HttpError('Project not found', { status: 404 });
417 }
418
419 where.projectId = request.query.projectId;
420 } else {
421 // If no projectId, get all projects in org and filter references
422 const projects = await db.project.findMany({
423 where: {
424 organizationId: request.client!.organizationId,
425 },
426 select: { id: true },
427 });
428
429 where.projectId = {
430 in: projects.map((p) => p.id),
431 };
432 }
433
434 const references = await db.reference.findMany({
435 where,
436 orderBy: {
437 createdAt: 'desc',
438 },
439 });
440
441 reply.send({ data: references });
442}
443
444export async function getReference(
445 request: FastifyRequest<{ Params: { id: string } }>,

Callers

nothing calls this directly

Calls 2

mapMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected