mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-05 05:55:21 +02:00
refactor(cloud): add deploy to external API
This commit is contained in:
@@ -48,6 +48,7 @@ import {
|
||||
addNewService,
|
||||
checkServiceAccess,
|
||||
IS_CLOUD,
|
||||
findProjectById,
|
||||
// uploadFileSchema
|
||||
} from "@dokploy/builders";
|
||||
import { uploadFileSchema } from "@/utils/schema";
|
||||
@@ -65,6 +66,14 @@ export const applicationRouter = createTRPCRouter({
|
||||
if (ctx.user.rol === "user") {
|
||||
await checkServiceAccess(ctx.user.authId, input.projectId, "create");
|
||||
}
|
||||
|
||||
const project = await findProjectById(input.projectId);
|
||||
if (project.adminId !== ctx.user.adminId) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "You are not authorized to access this project",
|
||||
});
|
||||
}
|
||||
const newApplication = await createApplication(input);
|
||||
|
||||
if (ctx.user.rol === "user") {
|
||||
@@ -545,7 +554,6 @@ export const applicationRouter = createTRPCRouter({
|
||||
});
|
||||
|
||||
await unzipDrop(zipFile, app);
|
||||
|
||||
const jobData: DeploymentJob = {
|
||||
applicationId: app.applicationId,
|
||||
titleLog: "Manual deployment",
|
||||
@@ -554,6 +562,12 @@ export const applicationRouter = createTRPCRouter({
|
||||
applicationType: "application",
|
||||
server: !!app.serverId,
|
||||
};
|
||||
if (IS_CLOUD && app.serverId) {
|
||||
jobData.serverId = app.serverId;
|
||||
await deploy(jobData);
|
||||
return true;
|
||||
}
|
||||
|
||||
await myQueue.add(
|
||||
"deployments",
|
||||
{ ...jobData },
|
||||
|
||||
Reference in New Issue
Block a user