(input: z.infer<typeof apiCreateDomain>)
| 15 | export type Domain = typeof domains.$inferSelect; |
| 16 | |
| 17 | export const createDomain = async (input: z.infer<typeof apiCreateDomain>) => { |
| 18 | const result = await db.transaction(async (tx) => { |
| 19 | const domain = await tx |
| 20 | .insert(domains) |
| 21 | .values({ |
| 22 | ...input, |
| 23 | host: input.host?.trim(), |
| 24 | } as typeof domains.$inferInsert) |
| 25 | .returning() |
| 26 | .then((response) => response[0]); |
| 27 | |
| 28 | if (!domain) { |
| 29 | throw new TRPCError({ |
| 30 | code: "BAD_REQUEST", |
| 31 | message: "Error creating domain", |
| 32 | }); |
| 33 | } |
| 34 | |
| 35 | if (domain.applicationId) { |
| 36 | const application = await findApplicationById(domain.applicationId); |
| 37 | await manageDomain(application, domain); |
| 38 | } |
| 39 | |
| 40 | return domain; |
| 41 | }); |
| 42 | |
| 43 | return result; |
| 44 | }; |
| 45 | |
| 46 | export const generateTraefikMeDomain = async ( |
| 47 | appName: string, |
no test coverage detected