Simplify Gitea authorization flow with shared utilities

This commit is contained in:
Jason Parks
2025-03-20 16:48:59 -06:00
parent a4e4d1c467
commit 530ad31aaa
9 changed files with 558 additions and 388 deletions

View File

@@ -1,4 +1,6 @@
// @ts-ignore: Cannot find module errors
import { db } from "@dokploy/server/db";
// @ts-ignore: Cannot find module errors
import {
type apiCreateGitea,
gitProvider,
@@ -32,7 +34,7 @@ export const createGitea = async (
});
}
await tx
const giteaProvider = await tx
.insert(gitea)
.values({
...input,
@@ -40,6 +42,20 @@ export const createGitea = async (
})
.returning()
.then((response: (typeof gitea.$inferSelect)[]) => response[0]);
if (!giteaProvider) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Error creating the Gitea provider",
});
}
// Return just the essential data needed by the frontend
return {
giteaId: giteaProvider.giteaId,
clientId: giteaProvider.clientId,
giteaUrl: giteaProvider.giteaUrl,
};
});
};

View File

@@ -1,7 +1,9 @@
import { createWriteStream } from "node:fs";
import * as fs from "node:fs/promises";
import { join } from "node:path";
// @ts-ignore: Cannot find module errors
import { paths } from "@dokploy/server/constants";
// @ts-ignore: Cannot find module errors
import { findGiteaById, updateGitea } from "@dokploy/server/services/gitea";
import { TRPCError } from "@trpc/server";
import { recreateDirectory } from "../filesystem/directory";