mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-19 19:44:29 +00: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 <[email protected]>
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import { db } from "@/server/db";
|
|
import { type apiCreateDestination, destinations } from "@/server/db/schema";
|
|
import { TRPCError } from "@trpc/server";
|
|
import { eq } from "drizzle-orm";
|
|
import { findAdmin } from "./admin";
|
|
|
|
export type Destination = typeof destinations.$inferSelect;
|
|
|
|
export const createDestintation = async (
|
|
input: typeof apiCreateDestination._type,
|
|
) => {
|
|
const adminResponse = await findAdmin();
|
|
const newDestination = await db
|
|
.insert(destinations)
|
|
.values({
|
|
...input,
|
|
adminId: adminResponse.adminId,
|
|
})
|
|
.returning()
|
|
.then((value) => value[0]);
|
|
|
|
if (!newDestination) {
|
|
throw new TRPCError({
|
|
code: "BAD_REQUEST",
|
|
message: "Error input: Inserting destination",
|
|
});
|
|
}
|
|
|
|
return newDestination;
|
|
};
|
|
|
|
export const findDestinationById = async (destinationId: string) => {
|
|
const destination = await db.query.destinations.findFirst({
|
|
where: eq(destinations.destinationId, destinationId),
|
|
});
|
|
if (!destination) {
|
|
throw new TRPCError({
|
|
code: "NOT_FOUND",
|
|
message: "Destination not found",
|
|
});
|
|
}
|
|
return destination;
|
|
};
|
|
|
|
export const removeDestinationById = async (destinationId: string) => {
|
|
const result = await db
|
|
.delete(destinations)
|
|
.where(eq(destinations.destinationId, destinationId))
|
|
.returning();
|
|
|
|
return result[0];
|
|
};
|
|
|
|
export const updateDestinationById = async (
|
|
destinationId: string,
|
|
destinationData: Partial<Destination>,
|
|
) => {
|
|
const result = await db
|
|
.update(destinations)
|
|
.set({
|
|
...destinationData,
|
|
})
|
|
.where(eq(destinations.destinationId, destinationId))
|
|
.returning();
|
|
|
|
return result[0];
|
|
};
|