mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { createInsertSchema } from "drizzle-zod";
|
|
import { z } from "zod";
|
|
import { nanoid } from "nanoid";
|
|
import { boolean, pgTable, text } from "drizzle-orm/pg-core";
|
|
import { generateAppName } from "./utils";
|
|
|
|
export const certificates = pgTable("certificate", {
|
|
certificateId: text("certificateId")
|
|
.notNull()
|
|
.primaryKey()
|
|
.$defaultFn(() => nanoid()),
|
|
name: text("name").notNull(),
|
|
certificateData: text("certificateData").notNull(),
|
|
privateKey: text("privateKey").notNull(),
|
|
certificatePath: text("certificatePath")
|
|
.notNull()
|
|
.$defaultFn(() => generateAppName("certificate"))
|
|
.unique(),
|
|
autoRenew: boolean("autoRenew"),
|
|
});
|
|
|
|
export const apiCreateCertificate = createInsertSchema(certificates, {
|
|
name: z.string().min(1),
|
|
certificateData: z.string().min(1),
|
|
privateKey: z.string().min(1),
|
|
autoRenew: z.boolean().optional(),
|
|
});
|
|
|
|
export const apiFindCertificate = z.object({
|
|
certificateId: z.string().min(1),
|
|
});
|
|
|
|
export const apiUpdateCertificate = z.object({
|
|
certificateId: z.string().min(1),
|
|
name: z.string().min(1).optional(),
|
|
certificateData: z.string().min(1).optional(),
|
|
privateKey: z.string().min(1).optional(),
|
|
autoRenew: z.boolean().optional(),
|
|
});
|
|
|
|
export const apiDeleteCertificate = z.object({
|
|
certificateId: z.string().min(1),
|
|
});
|