mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: new table and crud operations
This commit is contained in:
@@ -22,3 +22,4 @@ export * from "./shared";
|
||||
export * from "./compose";
|
||||
export * from "./registry";
|
||||
export * from "./notification";
|
||||
export * from "./ssh-key";
|
||||
|
||||
57
server/db/schema/ssh-key.ts
Normal file
57
server/db/schema/ssh-key.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { sshKeyCreate } from "@/server/db/validations";
|
||||
import { pgTable, text, time } from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema } from "drizzle-zod";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export const sshKeys = pgTable("ssh-key", {
|
||||
sshKeyId: text("sshKeyId")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
.$defaultFn(() => nanoid()),
|
||||
publicKey: text("publicKey").notNull(),
|
||||
name: text("name").notNull(),
|
||||
description: text("description"),
|
||||
createdAt: text("createdAt")
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date().toISOString()),
|
||||
lastUsedAt: text("lastUsedAt"),
|
||||
});
|
||||
|
||||
const createSchema = createInsertSchema(
|
||||
sshKeys,
|
||||
/* Private key is not stored in the DB */
|
||||
sshKeyCreate.omit({ privateKey: true }).shape,
|
||||
);
|
||||
|
||||
export const apiCreateSshKey = createSchema
|
||||
.pick({
|
||||
name: true,
|
||||
description: true,
|
||||
publicKey: true,
|
||||
})
|
||||
.merge(sshKeyCreate.pick({ privateKey: true }));
|
||||
|
||||
export const apiFindOneSshKey = createSchema
|
||||
.pick({
|
||||
sshKeyId: true,
|
||||
})
|
||||
.required();
|
||||
|
||||
export const apiRemoveSshKey = createSchema
|
||||
.pick({
|
||||
sshKeyId: true,
|
||||
})
|
||||
.required();
|
||||
|
||||
export const apiUpdateSshKey = createSchema
|
||||
.pick({
|
||||
name: true,
|
||||
description: true,
|
||||
})
|
||||
.merge(
|
||||
createSchema
|
||||
.pick({
|
||||
sshKeyId: true,
|
||||
})
|
||||
.required(),
|
||||
);
|
||||
Reference in New Issue
Block a user