MCPcopy
hub / github.com/Dokploy/dokploy / createMount

Function createMount

packages/server/src/services/mount.ts:25–79  ·  view source on GitHub ↗
(input: z.infer<typeof apiCreateMount>)

Source from the content-addressed store, hash-verified

23export type Mount = typeof mounts.$inferSelect;
24
25export const createMount = async (input: z.infer<typeof apiCreateMount>) => {
26 try {
27 const { serviceId, ...rest } = input;
28 const value = await db
29 .insert(mounts)
30 .values({
31 ...rest,
32 ...(input.serviceType === "application" && {
33 applicationId: serviceId,
34 }),
35 ...(input.serviceType === "compose" && {
36 composeId: serviceId,
37 }),
38 ...(input.serviceType === "libsql" && {
39 libsqlId: serviceId,
40 }),
41 ...(input.serviceType === "mariadb" && {
42 mariadbId: serviceId,
43 }),
44 ...(input.serviceType === "mongo" && {
45 mongoId: serviceId,
46 }),
47 ...(input.serviceType === "mysql" && {
48 mysqlId: serviceId,
49 }),
50 ...(input.serviceType === "postgres" && {
51 postgresId: serviceId,
52 }),
53 ...(input.serviceType === "redis" && {
54 redisId: serviceId,
55 }),
56 })
57 .returning()
58 .then((value) => value[0]);
59
60 if (!value) {
61 throw new TRPCError({
62 code: "BAD_REQUEST",
63 message: "Error inserting mount",
64 });
65 }
66
67 if (value.type === "file") {
68 await createFileMount(value.mountId);
69 }
70 return value;
71 } catch (error) {
72 console.log(error);
73 throw new TRPCError({
74 code: "BAD_REQUEST",
75 message: `Error ${error instanceof Error ? error.message : error}`,
76 cause: error,
77 });
78 }
79};
80
81export const createFileMount = async (mountId: string) => {
82 try {

Callers 10

mysql.tsFile · 0.90
mongo.tsFile · 0.90
mount.tsFile · 0.90
compose.tsFile · 0.90
redis.tsFile · 0.90
libsql.tsFile · 0.90
duplicateServiceFunction · 0.90
postgres.tsFile · 0.90
mariadb.tsFile · 0.90
ai.tsFile · 0.85

Calls 1

createFileMountFunction · 0.85

Tested by

no test coverage detected