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

Function listProjectsCore

packages/db/src/services/project.service.ts:145–184  ·  view source on GitHub ↗
(input: {
  clientType: 'root' | 'read';
  organizationId: string;
  projectId: string | null;
})

Source from the content-addressed store, hash-verified

143}
144
145export async function listProjectsCore(input: {
146 clientType: 'root' | 'read';
147 organizationId: string;
148 projectId: string | null;
149}) {
150 if (input.clientType === 'root') {
151 const projects = await db.project.findMany({
152 where: { organizationId: input.organizationId },
153 orderBy: { eventsCount: 'desc' },
154 select: {
155 id: true,
156 name: true,
157 organizationId: true,
158 eventsCount: true,
159 domain: true,
160 types: true,
161 },
162 });
163 return { clientType: 'root', projects };
164 }
165
166 const project = input.projectId
167 ? await db.project.findUnique({
168 where: { id: input.projectId },
169 select: {
170 id: true,
171 name: true,
172 organizationId: true,
173 eventsCount: true,
174 domain: true,
175 types: true,
176 },
177 })
178 : null;
179
180 return {
181 clientType: 'read',
182 projects: project ? [project] : [],
183 };
184}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected