mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-24 08:35:26 +02:00
* feat(create-turbo): apply official-starter transform * refactor: move folder * wip: monorepo * feat: add builf * refactor: add pr * update * add .env * refactor: update build * refactor: update build docker * refactor: add progress plain * refactor: remove node pty * refactor: remove * remove * refactor: update * refacotr: uopdate * refactor: add remix app * add env * refactor: add pnpm start * refactor: remove * refactor: remove folders * refactor: remove .dockerfile * chore: update biome * test * choe: add husky * remove .docker folder * feat: add docs website * refactor: add husky * chore(version): bump version * refactor: add new changes * refactor: update circle path * refactor: update * refactor: update * refactor: update dockerfile * refactor: update dockerfile * refactor: update command * refactor: update * refactor: update dockerfile * refactor: add tsx * refactor: update dockerfile * refactor: add deps * refactor: up[date * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: yuodate * refactor: remove * refactor: uncomment * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: updare * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: imprt * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: remove * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: change path * refactor: update * refactor: update * refactor: upoadte * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: add * refactor: update * refactor: update * refactor: add * refactor: update * refactor: remove * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: removed * refactor: update * refactor: update * refactor: update * refactor: add config * refactor: update * refactor: add * refactor: update * refactor: update * refactor: remove * refactor: update * refactor: remove * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: add docs * refactor: update * refactor: add website * refactor: update * refactor: update * refactor: update * refactor: update * refactor: add ignore builds * refactor: update * refactor: update * refactor: add * refactor: update * refactor: update * refactor: remove needs * refactor: update * refactor: update * refactor: add config * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: remove * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: add * refactor: update * refactor: update * refactor: update * refactor: update * refactor: upodate * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update * refactor: update package json * refactor: add biome * refactor: add sponsors * refactor: update * refactor: update * refactor: remove * refactor: update * refactor: update * refactor: update * refactor: update scripts * refactor: remove * refactor: update * refactor: remove --------- Co-authored-by: Turbobot <turbobot@vercel.com>
79 lines
1.6 KiB
TypeScript
79 lines
1.6 KiB
TypeScript
import { db } from "@/server/db";
|
|
import {
|
|
type apiCreateSshKey,
|
|
type apiFindOneSshKey,
|
|
type apiRemoveSshKey,
|
|
type apiUpdateSshKey,
|
|
sshKeys,
|
|
} from "@/server/db/schema";
|
|
import { removeSSHKey, saveSSHKey } from "@/server/utils/filesystem/ssh";
|
|
import { TRPCError } from "@trpc/server";
|
|
import { eq } from "drizzle-orm";
|
|
|
|
export const createSshKey = async ({
|
|
privateKey,
|
|
...input
|
|
}: typeof apiCreateSshKey._type) => {
|
|
await db.transaction(async (tx) => {
|
|
const sshKey = await tx
|
|
.insert(sshKeys)
|
|
.values(input)
|
|
.returning()
|
|
.then((response) => response[0])
|
|
.catch((e) => console.error(e));
|
|
|
|
if (sshKey) {
|
|
saveSSHKey(sshKey.sshKeyId, sshKey.publicKey, privateKey);
|
|
}
|
|
|
|
if (!sshKey) {
|
|
throw new TRPCError({
|
|
code: "BAD_REQUEST",
|
|
message: "Error to create the ssh key",
|
|
});
|
|
}
|
|
return sshKey;
|
|
});
|
|
};
|
|
|
|
export const removeSSHKeyById = async (
|
|
sshKeyId: (typeof apiRemoveSshKey._type)["sshKeyId"],
|
|
) => {
|
|
const result = await db
|
|
.delete(sshKeys)
|
|
.where(eq(sshKeys.sshKeyId, sshKeyId))
|
|
.returning();
|
|
|
|
removeSSHKey(sshKeyId);
|
|
|
|
return result[0];
|
|
};
|
|
|
|
export const updateSSHKeyById = async ({
|
|
sshKeyId,
|
|
...input
|
|
}: typeof apiUpdateSshKey._type) => {
|
|
const result = await db
|
|
.update(sshKeys)
|
|
.set(input)
|
|
.where(eq(sshKeys.sshKeyId, sshKeyId))
|
|
.returning();
|
|
|
|
return result[0];
|
|
};
|
|
|
|
export const findSSHKeyById = async (
|
|
sshKeyId: (typeof apiFindOneSshKey._type)["sshKeyId"],
|
|
) => {
|
|
const sshKey = await db.query.sshKeys.findFirst({
|
|
where: eq(sshKeys.sshKeyId, sshKeyId),
|
|
});
|
|
if (!sshKey) {
|
|
throw new TRPCError({
|
|
code: "NOT_FOUND",
|
|
message: "SSH Key not found",
|
|
});
|
|
}
|
|
return sshKey;
|
|
};
|