mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: slugify and add hash to appName
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
|||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
import { registry } from "./registry";
|
import { registry } from "./registry";
|
||||||
|
import { generatePassword } from "@/templates/utils";
|
||||||
|
|
||||||
export const sourceType = pgEnum("sourceType", ["docker", "git", "github"]);
|
export const sourceType = pgEnum("sourceType", ["docker", "git", "github"]);
|
||||||
|
|
||||||
@@ -307,12 +308,17 @@ const createSchema = createInsertSchema(applications, {
|
|||||||
networkSwarm: NetworkSwarmSchema.nullable(),
|
networkSwarm: NetworkSwarmSchema.nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiCreateApplication = createSchema.pick({
|
export const apiCreateApplication = createSchema
|
||||||
name: true,
|
.pick({
|
||||||
appName: true,
|
name: true,
|
||||||
description: true,
|
appName: true,
|
||||||
projectId: true,
|
description: true,
|
||||||
});
|
projectId: true,
|
||||||
|
})
|
||||||
|
.transform((data) => ({
|
||||||
|
...data,
|
||||||
|
appName: `${data.appName}-${generatePassword(6)}` || generateAppName("app"),
|
||||||
|
}));
|
||||||
|
|
||||||
export const apiFindOneApplication = createSchema
|
export const apiFindOneApplication = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { deployments } from "./deployment";
|
|||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
import { applicationStatus } from "./shared";
|
import { applicationStatus } from "./shared";
|
||||||
import { mounts } from "./mount";
|
import { mounts } from "./mount";
|
||||||
|
import { generatePassword } from "@/templates/utils";
|
||||||
|
|
||||||
export const sourceTypeCompose = pgEnum("sourceTypeCompose", [
|
export const sourceTypeCompose = pgEnum("sourceTypeCompose", [
|
||||||
"git",
|
"git",
|
||||||
@@ -74,12 +75,19 @@ const createSchema = createInsertSchema(compose, {
|
|||||||
composeType: z.enum(["docker-compose", "stack"]).optional(),
|
composeType: z.enum(["docker-compose", "stack"]).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiCreateCompose = createSchema.pick({
|
export const apiCreateCompose = createSchema
|
||||||
name: true,
|
.pick({
|
||||||
description: true,
|
name: true,
|
||||||
projectId: true,
|
description: true,
|
||||||
composeType: true,
|
projectId: true,
|
||||||
});
|
composeType: true,
|
||||||
|
appName: true,
|
||||||
|
})
|
||||||
|
.transform((data) => ({
|
||||||
|
...data,
|
||||||
|
appName:
|
||||||
|
`${data.appName}-${generatePassword(6)}` || generateAppName("compose"),
|
||||||
|
}));
|
||||||
|
|
||||||
export const apiCreateComposeByTemplate = createSchema
|
export const apiCreateComposeByTemplate = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { projects } from "./project";
|
|||||||
import { backups } from "./backups";
|
import { backups } from "./backups";
|
||||||
import { mounts } from "./mount";
|
import { mounts } from "./mount";
|
||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
|
import { generatePassword } from "@/templates/utils";
|
||||||
|
|
||||||
export const mariadb = pgTable("mariadb", {
|
export const mariadb = pgTable("mariadb", {
|
||||||
mariadbId: text("mariadbId")
|
mariadbId: text("mariadbId")
|
||||||
@@ -88,7 +89,12 @@ export const apiCreateMariaDB = createSchema
|
|||||||
databaseUser: true,
|
databaseUser: true,
|
||||||
databasePassword: true,
|
databasePassword: true,
|
||||||
})
|
})
|
||||||
.required();
|
.required()
|
||||||
|
.transform((data) => ({
|
||||||
|
...data,
|
||||||
|
appName:
|
||||||
|
`${data.appName}-${generatePassword(6)}` || generateAppName("mariadb"),
|
||||||
|
}));
|
||||||
|
|
||||||
export const apiFindOneMariaDB = createSchema
|
export const apiFindOneMariaDB = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { projects } from "./project";
|
|||||||
import { backups } from "./backups";
|
import { backups } from "./backups";
|
||||||
import { mounts } from "./mount";
|
import { mounts } from "./mount";
|
||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
|
import { generatePassword } from "@/templates/utils";
|
||||||
|
|
||||||
export const mongo = pgTable("mongo", {
|
export const mongo = pgTable("mongo", {
|
||||||
mongoId: text("mongoId")
|
mongoId: text("mongoId")
|
||||||
@@ -80,7 +81,12 @@ export const apiCreateMongo = createSchema
|
|||||||
databaseUser: true,
|
databaseUser: true,
|
||||||
databasePassword: true,
|
databasePassword: true,
|
||||||
})
|
})
|
||||||
.required();
|
.required()
|
||||||
|
.transform((data) => ({
|
||||||
|
...data,
|
||||||
|
appName:
|
||||||
|
`${data.appName}-${generatePassword(6)}` || generateAppName("postgres"),
|
||||||
|
}));
|
||||||
|
|
||||||
export const apiFindOneMongo = createSchema
|
export const apiFindOneMongo = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { projects } from "./project";
|
|||||||
import { backups } from "./backups";
|
import { backups } from "./backups";
|
||||||
import { mounts } from "./mount";
|
import { mounts } from "./mount";
|
||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
|
import { generatePassword } from "@/templates/utils";
|
||||||
|
|
||||||
export const mysql = pgTable("mysql", {
|
export const mysql = pgTable("mysql", {
|
||||||
mysqlId: text("mysqlId")
|
mysqlId: text("mysqlId")
|
||||||
@@ -86,7 +87,12 @@ export const apiCreateMySql = createSchema
|
|||||||
databasePassword: true,
|
databasePassword: true,
|
||||||
databaseRootPassword: true,
|
databaseRootPassword: true,
|
||||||
})
|
})
|
||||||
.required();
|
.required()
|
||||||
|
.transform((data) => ({
|
||||||
|
...data,
|
||||||
|
appName:
|
||||||
|
`${data.appName}-${generatePassword(6)}` || generateAppName("mysql"),
|
||||||
|
}));
|
||||||
|
|
||||||
export const apiFindOneMySql = createSchema
|
export const apiFindOneMySql = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { projects } from "./project";
|
|||||||
import { backups } from "./backups";
|
import { backups } from "./backups";
|
||||||
import { mounts } from "./mount";
|
import { mounts } from "./mount";
|
||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
|
import { generatePassword } from "@/templates/utils";
|
||||||
|
|
||||||
export const postgres = pgTable("postgres", {
|
export const postgres = pgTable("postgres", {
|
||||||
postgresId: text("postgresId")
|
postgresId: text("postgresId")
|
||||||
@@ -82,7 +83,12 @@ export const apiCreatePostgres = createSchema
|
|||||||
projectId: true,
|
projectId: true,
|
||||||
description: true,
|
description: true,
|
||||||
})
|
})
|
||||||
.required();
|
.required()
|
||||||
|
.transform((data) => ({
|
||||||
|
...data,
|
||||||
|
appName:
|
||||||
|
`${data.appName}-${generatePassword(6)}` || generateAppName("postgres"),
|
||||||
|
}));
|
||||||
|
|
||||||
export const apiFindOnePostgres = createSchema
|
export const apiFindOnePostgres = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { integer, pgTable, text } from "drizzle-orm/pg-core";
|
|||||||
import { projects } from "./project";
|
import { projects } from "./project";
|
||||||
import { mounts } from "./mount";
|
import { mounts } from "./mount";
|
||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
|
import { generatePassword } from "@/templates/utils";
|
||||||
|
|
||||||
export const redis = pgTable("redis", {
|
export const redis = pgTable("redis", {
|
||||||
redisId: text("redisId")
|
redisId: text("redisId")
|
||||||
@@ -75,8 +76,12 @@ export const apiCreateRedis = createSchema
|
|||||||
projectId: true,
|
projectId: true,
|
||||||
description: true,
|
description: true,
|
||||||
})
|
})
|
||||||
|
.required()
|
||||||
.required();
|
.transform((data) => ({
|
||||||
|
...data,
|
||||||
|
appName:
|
||||||
|
`${data.appName}-${generatePassword(6)}` || generateAppName("redis"),
|
||||||
|
}));
|
||||||
|
|
||||||
export const apiFindOneRedis = createSchema
|
export const apiFindOneRedis = createSchema
|
||||||
.pick({
|
.pick({
|
||||||
|
|||||||
Reference in New Issue
Block a user