refactor: slugify and add hash to appName

This commit is contained in:
Mauricio Siu
2024-06-08 16:41:05 -06:00
parent 9a4f79f9e6
commit 72c366aa10
7 changed files with 61 additions and 18 deletions

View File

@@ -8,6 +8,7 @@ import { projects } from "./project";
import { backups } from "./backups";
import { mounts } from "./mount";
import { generateAppName } from "./utils";
import { generatePassword } from "@/templates/utils";
export const postgres = pgTable("postgres", {
postgresId: text("postgresId")
@@ -82,7 +83,12 @@ export const apiCreatePostgres = createSchema
projectId: true,
description: true,
})
.required();
.required()
.transform((data) => ({
...data,
appName:
`${data.appName}-${generatePassword(6)}` || generateAppName("postgres"),
}));
export const apiFindOnePostgres = createSchema
.pick({