mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: prevent update appName in services
This commit is contained in:
@@ -17,9 +17,9 @@ export const generateAppName = (type: string) => {
|
||||
|
||||
export const cleanAppName = (appName?: string) => {
|
||||
if (!appName) {
|
||||
return appName;
|
||||
return appName?.toLowerCase();
|
||||
}
|
||||
return appName.trim().replace(/ /g, "-");
|
||||
return appName.trim().replace(/ /g, "-").toLowerCase();
|
||||
};
|
||||
|
||||
export const buildAppName = (type: string, baseAppName?: string) => {
|
||||
|
||||
@@ -138,11 +138,11 @@ export const updateApplication = async (
|
||||
applicationId: string,
|
||||
applicationData: Partial<Application>,
|
||||
) => {
|
||||
const { appName, ...rest } = applicationData;
|
||||
const application = await db
|
||||
.update(applications)
|
||||
.set({
|
||||
...applicationData,
|
||||
appName: cleanAppName(applicationData.appName),
|
||||
...rest,
|
||||
})
|
||||
.where(eq(applications.applicationId, applicationId))
|
||||
.returning();
|
||||
|
||||
@@ -184,11 +184,11 @@ export const updateCompose = async (
|
||||
composeId: string,
|
||||
composeData: Partial<Compose>,
|
||||
) => {
|
||||
const { appName, ...rest } = composeData;
|
||||
const composeResult = await db
|
||||
.update(compose)
|
||||
.set({
|
||||
...composeData,
|
||||
appName: cleanAppName(composeData.appName),
|
||||
...rest,
|
||||
})
|
||||
.where(eq(compose.composeId, composeId))
|
||||
.returning();
|
||||
|
||||
@@ -80,11 +80,11 @@ export const updateMariadbById = async (
|
||||
mariadbId: string,
|
||||
mariadbData: Partial<Mariadb>,
|
||||
) => {
|
||||
const { appName, ...rest } = mariadbData;
|
||||
const result = await db
|
||||
.update(mariadb)
|
||||
.set({
|
||||
...mariadbData,
|
||||
appName: cleanAppName(mariadbData.appName),
|
||||
...rest,
|
||||
})
|
||||
.where(eq(mariadb.mariadbId, mariadbId))
|
||||
.returning();
|
||||
|
||||
@@ -72,11 +72,11 @@ export const updateMongoById = async (
|
||||
mongoId: string,
|
||||
mongoData: Partial<Mongo>,
|
||||
) => {
|
||||
const { appName, ...rest } = mongoData;
|
||||
const result = await db
|
||||
.update(mongo)
|
||||
.set({
|
||||
...mongoData,
|
||||
appName: cleanAppName(mongoData.appName),
|
||||
...rest,
|
||||
})
|
||||
.where(eq(mongo.mongoId, mongoId))
|
||||
.returning();
|
||||
|
||||
@@ -76,11 +76,11 @@ export const updateMySqlById = async (
|
||||
mysqlId: string,
|
||||
mysqlData: Partial<MySql>,
|
||||
) => {
|
||||
const { appName, ...rest } = mysqlData;
|
||||
const result = await db
|
||||
.update(mysql)
|
||||
.set({
|
||||
...mysqlData,
|
||||
appName: cleanAppName(mysqlData.appName),
|
||||
...rest,
|
||||
})
|
||||
.where(eq(mysql.mysqlId, mysqlId))
|
||||
.returning();
|
||||
|
||||
@@ -94,11 +94,11 @@ export const updatePostgresById = async (
|
||||
postgresId: string,
|
||||
postgresData: Partial<Postgres>,
|
||||
) => {
|
||||
const { appName, ...rest } = postgresData;
|
||||
const result = await db
|
||||
.update(postgres)
|
||||
.set({
|
||||
...postgresData,
|
||||
appName: cleanAppName(postgresData.appName),
|
||||
...rest,
|
||||
})
|
||||
.where(eq(postgres.postgresId, postgresId))
|
||||
.returning();
|
||||
|
||||
@@ -68,11 +68,11 @@ export const updateRedisById = async (
|
||||
redisId: string,
|
||||
redisData: Partial<Redis>,
|
||||
) => {
|
||||
const { appName, ...rest } = redisData;
|
||||
const result = await db
|
||||
.update(redis)
|
||||
.set({
|
||||
...redisData,
|
||||
appName: cleanAppName(redisData.appName),
|
||||
...rest,
|
||||
})
|
||||
.where(eq(redis.redisId, redisId))
|
||||
.returning();
|
||||
|
||||
Reference in New Issue
Block a user