Skip to content

Commit 479e8bb

Browse files
committed
feat: refactor serviceColumns for project access and enhance data retrieval
1 parent b976c7b commit 479e8bb

2 files changed

Lines changed: 34 additions & 9 deletions

File tree

‎apps/dokploy/server/api/routers/project.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
checkProjectAccess,
3939
findMemberByUserId,
4040
} from "@dokploy/server/services/permission";
41+
import { serviceColumns } from "@dokploy/server/services/project";
4142
import { TRPCError } from "@trpc/server";
4243
import { and, desc, eq, ilike, or, sql } from "drizzle-orm";
4344
import type { AnyPgColumn } from "drizzle-orm/pg-core";
@@ -130,39 +131,63 @@ export const projectRouter = createTRPCRouter({
130131
environments: {
131132
with: {
132133
applications: {
134+
columns: {
135+
...serviceColumns,
136+
applicationId: true,
137+
icon: true,
138+
},
139+
with: { server: { columns: { name: true } } },
133140
where: buildServiceFilter(
134141
applications.applicationId,
135142
accessedServices,
136143
),
137144
},
138145
compose: {
146+
columns: {
147+
...serviceColumns,
148+
composeId: true,
149+
composeStatus: true,
150+
},
151+
with: { server: { columns: { name: true } } },
139152
where: buildServiceFilter(
140153
compose.composeId,
141154
accessedServices,
142155
),
143156
},
144157
libsql: {
158+
columns: { ...serviceColumns, libsqlId: true },
159+
with: { server: { columns: { name: true } } },
145160
where: buildServiceFilter(libsql.libsqlId, accessedServices),
146161
},
147162
mariadb: {
163+
columns: { ...serviceColumns, mariadbId: true },
164+
with: { server: { columns: { name: true } } },
148165
where: buildServiceFilter(
149166
mariadb.mariadbId,
150167
accessedServices,
151168
),
152169
},
153170
mongo: {
171+
columns: { ...serviceColumns, mongoId: true },
172+
with: { server: { columns: { name: true } } },
154173
where: buildServiceFilter(mongo.mongoId, accessedServices),
155174
},
156175
mysql: {
176+
columns: { ...serviceColumns, mysqlId: true },
177+
with: { server: { columns: { name: true } } },
157178
where: buildServiceFilter(mysql.mysqlId, accessedServices),
158179
},
159180
postgres: {
181+
columns: { ...serviceColumns, postgresId: true },
182+
with: { server: { columns: { name: true } } },
160183
where: buildServiceFilter(
161184
postgres.postgresId,
162185
accessedServices,
163186
),
164187
},
165188
redis: {
189+
columns: { ...serviceColumns, redisId: true },
190+
with: { server: { columns: { name: true } } },
166191
where: buildServiceFilter(redis.redisId, accessedServices),
167192
},
168193
},

‎packages/server/src/services/project.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ export const createProject = async (
4747
};
4848
};
4949

50-
export const findProjectById = async (projectId: string) => {
51-
const serviceColumns = {
52-
name: true,
53-
description: true,
54-
appName: true,
55-
createdAt: true,
56-
serverId: true,
57-
applicationStatus: true,
58-
} as const;
50+
export const serviceColumns = {
51+
name: true,
52+
description: true,
53+
appName: true,
54+
createdAt: true,
55+
serverId: true,
56+
applicationStatus: true,
57+
} as const;
5958

59+
export const findProjectById = async (projectId: string) => {
6060
const project = await db.query.projects.findFirst({
6161
where: eq(projects.projectId, projectId),
6262
with: {

0 commit comments

Comments
 (0)