diff --git a/apps/dokploy/pages/api/providers/github/setup.ts b/apps/dokploy/pages/api/providers/github/setup.ts index 3ad7e9087..b9bd51ffb 100644 --- a/apps/dokploy/pages/api/providers/github/setup.ts +++ b/apps/dokploy/pages/api/providers/github/setup.ts @@ -1,4 +1,4 @@ -import { createGithub } from "@/server/api/services/git-provider"; +import { createGithub } from "@/server/api/services/github"; import { db } from "@/server/db"; import { github } from "@/server/db/schema"; import { eq } from "drizzle-orm"; diff --git a/apps/dokploy/pages/api/providers/gitlab/callback.ts b/apps/dokploy/pages/api/providers/gitlab/callback.ts index e536ee2ca..54260b8b3 100644 --- a/apps/dokploy/pages/api/providers/gitlab/callback.ts +++ b/apps/dokploy/pages/api/providers/gitlab/callback.ts @@ -1,7 +1,4 @@ -import { - findGitlabById, - updateGitlab, -} from "@/server/api/services/git-provider"; +import { findGitlabById, updateGitlab } from "@/server/api/services/gitlab"; import type { NextApiRequest, NextApiResponse } from "next"; export default async function handler( diff --git a/apps/dokploy/server/api/routers/gitlab.ts b/apps/dokploy/server/api/routers/gitlab.ts index d83d69193..797979cf5 100644 --- a/apps/dokploy/server/api/routers/gitlab.ts +++ b/apps/dokploy/server/api/routers/gitlab.ts @@ -16,6 +16,7 @@ import { import { TRPCError } from "@trpc/server"; import { createGitlab, findGitlabById, updateGitlab } from "../services/gitlab"; import { db } from "@/server/db"; +import { updateGitProvider } from "../services/git-provider"; export const gitlabRouter = createTRPCRouter({ create: protectedProcedure @@ -81,6 +82,12 @@ export const gitlabRouter = createTRPCRouter({ update: protectedProcedure .input(apiUpdateGitlab) .mutation(async ({ input }) => { - return await updateGitlab(input.gitlabId, input); + if (input.name) { + await updateGitProvider(input.gitProviderId, { + name: input.name, + }); + } else { + await updateGitlab(input.gitlabId, input); + } }), }); diff --git a/apps/dokploy/server/api/services/gitlab.ts b/apps/dokploy/server/api/services/gitlab.ts index acc117e60..d3dca3a80 100644 --- a/apps/dokploy/server/api/services/gitlab.ts +++ b/apps/dokploy/server/api/services/gitlab.ts @@ -1,7 +1,6 @@ import { db } from "@/server/db"; import { type apiCreateGitlab, - type apiUpdateGitlab, type bitbucket, type github, gitlab, @@ -63,33 +62,6 @@ export const findGitlabById = async (gitlabId: string) => { }; export const updateGitlab = async ( - gitlabId: string, - input: typeof apiUpdateGitlab._type, -) => { - return await db.transaction(async (tx) => { - const result = await tx - .update(gitlab) - .set({ - ...input, - }) - .where(eq(gitlab.gitlabId, gitlabId)) - .returning(); - - if (input.name) { - await tx - .update(gitProvider) - .set({ - name: input.name, - }) - .where(eq(gitProvider.gitProviderId, input.gitProviderId)) - .returning(); - } - - return result[0]; - }); -}; - -export const updateGitlabComplete = async ( gitlabId: string, input: Partial, ) => { diff --git a/apps/dokploy/server/utils/providers/gitlab.ts b/apps/dokploy/server/utils/providers/gitlab.ts index 737f5e5b2..84e1f18ee 100644 --- a/apps/dokploy/server/utils/providers/gitlab.ts +++ b/apps/dokploy/server/utils/providers/gitlab.ts @@ -8,7 +8,7 @@ import type { InferResultType } from "@/server/types/with"; import type { Compose } from "@/server/api/services/compose"; import { findGitlabById, - updateGitlabComplete, + updateGitlab, type Gitlab, } from "@/server/api/services/gitlab"; import type { apiGitlabTestConnection } from "@/server/db/schema"; @@ -48,7 +48,7 @@ export const refreshGitlabToken = async (gitlabProviderId: string) => { console.log("Refreshed token"); - await updateGitlabComplete(gitlabProviderId, { + await updateGitlab(gitlabProviderId, { accessToken: data.access_token, refreshToken: data.refresh_token, expiresAt,