mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Simplify Gitea authorization flow with shared utilities
This commit is contained in:
@@ -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,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user