mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Refactor Gitea integration and update related components
This commit is contained in:
@@ -6,23 +6,24 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
||||
export type Gitea = typeof gitea.$inferSelect;
|
||||
|
||||
export const createGitea = async (
|
||||
input: typeof apiCreateGitea._type,
|
||||
organizationId: string,
|
||||
) => {
|
||||
// @ts-ignore - Complex transaction type - Added because proper typing in Drizzle in not sufficient
|
||||
return await db.transaction(async (tx) => {
|
||||
// Insert new Git provider (Gitea)
|
||||
const newGitProvider = await tx
|
||||
.insert(gitProvider)
|
||||
.values({
|
||||
providerType: "gitea", // Set providerType to 'gitea'
|
||||
providerType: "gitea",
|
||||
organizationId: organizationId,
|
||||
name: input.name,
|
||||
})
|
||||
.returning()
|
||||
.then((response) => response[0]);
|
||||
.then((response: typeof gitProvider.$inferSelect[]) => response[0]);
|
||||
|
||||
if (!newGitProvider) {
|
||||
throw new TRPCError({
|
||||
@@ -31,7 +32,6 @@ export const createGitea = async (
|
||||
});
|
||||
}
|
||||
|
||||
// Insert the Gitea data into the `gitea` table
|
||||
await tx
|
||||
.insert(gitea)
|
||||
.values({
|
||||
@@ -39,7 +39,7 @@ export const createGitea = async (
|
||||
gitProviderId: newGitProvider?.gitProviderId,
|
||||
})
|
||||
.returning()
|
||||
.then((response) => response[0]);
|
||||
.then((response: typeof gitea.$inferSelect[]) => response[0]);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -84,7 +84,6 @@ export const updateGitea = async (giteaId: string, input: Partial<Gitea>) => {
|
||||
.where(eq(gitea.giteaId, giteaId))
|
||||
.returning();
|
||||
|
||||
// Explicitly type the result and handle potential undefined
|
||||
const result = updateResult[0] as Gitea | undefined;
|
||||
|
||||
if (!result) {
|
||||
@@ -97,4 +96,4 @@ export const updateGitea = async (giteaId: string, input: Partial<Gitea>) => {
|
||||
console.error("Error updating Gitea provider:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createWriteStream } from "node:fs";
|
||||
import fs from "node:fs/promises";
|
||||
import * as fs from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { paths } from "@dokploy/server/constants";
|
||||
import { findGiteaById, updateGitea } from "@dokploy/server/services/gitea";
|
||||
|
||||
Reference in New Issue
Block a user