( input: z.infer<typeof apiCreateCompose>, )
| 47 | export type Compose = typeof compose.$inferSelect; |
| 48 | |
| 49 | export const createCompose = async ( |
| 50 | input: z.infer<typeof apiCreateCompose>, |
| 51 | ) => { |
| 52 | const appName = buildAppName("compose", input.appName); |
| 53 | |
| 54 | const valid = await validUniqueServerAppName(appName); |
| 55 | if (!valid) { |
| 56 | throw new TRPCError({ |
| 57 | code: "CONFLICT", |
| 58 | message: "Service with this 'AppName' already exists", |
| 59 | }); |
| 60 | } |
| 61 | |
| 62 | const newDestination = await db |
| 63 | .insert(compose) |
| 64 | .values({ |
| 65 | ...input, |
| 66 | composeFile: input.composeFile || "", |
| 67 | appName, |
| 68 | }) |
| 69 | .returning() |
| 70 | .then((value) => value[0]); |
| 71 | |
| 72 | if (!newDestination) { |
| 73 | throw new TRPCError({ |
| 74 | code: "BAD_REQUEST", |
| 75 | message: "Error input: Inserting compose", |
| 76 | }); |
| 77 | } |
| 78 | |
| 79 | return newDestination; |
| 80 | }; |
| 81 | |
| 82 | export const createComposeByTemplate = async ( |
| 83 | input: typeof compose.$inferInsert, |
no test coverage detected