refactor: update project structure to use environmentId instead of projectId across components and API routes; implement environment management features

This commit is contained in:
Mauricio Siu
2025-09-01 19:48:20 -06:00
parent 6fc325fe95
commit 72f8a28f4f
31 changed files with 8527 additions and 1401 deletions
+4 -1
View File
@@ -76,6 +76,7 @@ export const createApplication = async (
});
}
console.log("input", input);
return await db.transaction(async (tx) => {
const newApplication = await tx
.insert(applications)
@@ -86,6 +87,8 @@ export const createApplication = async (
.returning()
.then((value) => value[0]);
console.log("newApplication", newApplication);
if (!newApplication) {
throw new TRPCError({
code: "BAD_REQUEST",
@@ -105,7 +108,7 @@ export const findApplicationById = async (applicationId: string) => {
const application = await db.query.applications.findFirst({
where: eq(applications.applicationId, applicationId),
with: {
project: true,
environment: true,
domains: true,
deployments: true,
mounts: true,
@@ -33,6 +33,16 @@ export const createEnvironment = async (
export const findEnvironmentById = async (environmentId: string) => {
const environment = await db.query.environments.findFirst({
where: eq(environments.environmentId, environmentId),
with: {
applications: true,
mariadb: true,
mongo: true,
mysql: true,
postgres: true,
redis: true,
compose: true,
project: true,
},
});
if (!environment) {
throw new TRPCError({
+1 -1
View File
@@ -99,7 +99,7 @@ export const updateProjectById = async (
};
export const validUniqueServerAppName = async (appName: string) => {
const query = await db.query.projects.findMany({
const query = await db.query.environments.findMany({
with: {
applications: {
where: eq(applications.appName, appName),