mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: Update Gitea provider components and API handling
- Adjusted GiteaProviderSchema to ensure watchPaths are correctly initialized and validated. - Refactored SaveGiteaProvider and SaveGiteaProviderCompose components for improved state management and UI consistency. - Simplified API router methods for Gitea, enhancing readability and error handling. - Updated database schema and service functions for better clarity and maintainability. - Removed unnecessary comments and improved logging for better debugging.
This commit is contained in:
@@ -5,13 +5,12 @@ import { nanoid } from "nanoid";
|
||||
import { z } from "zod";
|
||||
import { gitProvider } from "./git-provider";
|
||||
|
||||
// Gitea table definition
|
||||
export const gitea = pgTable("gitea", {
|
||||
giteaId: text("giteaId")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
.$defaultFn(() => nanoid()), // Using nanoid for unique ID
|
||||
giteaUrl: text("giteaUrl").default("https://gitea.com").notNull(), // Default URL for Gitea
|
||||
.$defaultFn(() => nanoid()),
|
||||
giteaUrl: text("giteaUrl").default("https://gitea.com").notNull(),
|
||||
redirectUri: text("redirect_uri"),
|
||||
clientId: text("client_id"),
|
||||
clientSecret: text("client_secret"),
|
||||
@@ -26,7 +25,6 @@ export const gitea = pgTable("gitea", {
|
||||
lastAuthenticatedAt: integer("last_authenticated_at"),
|
||||
});
|
||||
|
||||
// Gitea relations with gitProvider
|
||||
export const giteaProviderRelations = relations(gitea, ({ one }) => ({
|
||||
gitProvider: one(gitProvider, {
|
||||
fields: [gitea.gitProviderId],
|
||||
@@ -34,10 +32,8 @@ export const giteaProviderRelations = relations(gitea, ({ one }) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
// Create schema for Gitea
|
||||
const createSchema = createInsertSchema(gitea);
|
||||
|
||||
// API schema for creating a Gitea instance
|
||||
export const apiCreateGitea = createSchema.extend({
|
||||
clientId: z.string().optional(),
|
||||
clientSecret: z.string().optional(),
|
||||
@@ -54,14 +50,12 @@ export const apiCreateGitea = createSchema.extend({
|
||||
lastAuthenticatedAt: z.number().optional(),
|
||||
});
|
||||
|
||||
// API schema for finding one Gitea instance
|
||||
export const apiFindOneGitea = createSchema
|
||||
.extend({
|
||||
giteaId: z.string().min(1),
|
||||
})
|
||||
.pick({ giteaId: true });
|
||||
|
||||
// API schema for testing Gitea connection
|
||||
export const apiGiteaTestConnection = createSchema
|
||||
.extend({
|
||||
organizationName: z.string().optional(),
|
||||
@@ -70,7 +64,6 @@ export const apiGiteaTestConnection = createSchema
|
||||
|
||||
export type ApiGiteaTestConnection = z.infer<typeof apiGiteaTestConnection>;
|
||||
|
||||
// API schema for finding branches in Gitea
|
||||
export const apiFindGiteaBranches = z.object({
|
||||
id: z.number().optional(),
|
||||
owner: z.string().min(1),
|
||||
@@ -78,7 +71,6 @@ export const apiFindGiteaBranches = z.object({
|
||||
giteaId: z.string().optional(),
|
||||
});
|
||||
|
||||
// API schema for updating Gitea instance
|
||||
export const apiUpdateGitea = createSchema.extend({
|
||||
clientId: z.string().optional(),
|
||||
clientSecret: z.string().optional(),
|
||||
|
||||
Reference in New Issue
Block a user