refactor(cloud): add validation to prevent create applications without server

This commit is contained in:
Mauricio Siu
2024-10-04 21:31:22 -06:00
parent 7c4987d84d
commit 09ef851372
8 changed files with 375 additions and 339 deletions

View File

@@ -25,6 +25,7 @@ import {
removePostgresById,
updatePostgresById,
findProjectById,
IS_CLOUD,
} from "@dokploy/builders";
export const postgresRouter = createTRPCRouter({
@@ -36,6 +37,13 @@ export const postgresRouter = createTRPCRouter({
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
}
if (IS_CLOUD && !input.serverId) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "You need to use a server to create a postgres",
});
}
const project = await findProjectById(input.projectId);
if (project.adminId !== ctx.user.adminId) {
throw new TRPCError({