mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor(domains): make traefik domains generate in a single click
This commit is contained in:
@@ -37,48 +37,34 @@ export const createDomain = async (input: typeof apiCreateDomain._type) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const generateDomain = async (
|
||||
input: typeof apiFindDomainByApplication._type,
|
||||
) => {
|
||||
const application = await findApplicationById(input.applicationId);
|
||||
export const generateTraefikMeDomain = async (appName: string) => {
|
||||
const admin = await findAdmin();
|
||||
const domain = await createDomain({
|
||||
applicationId: application.applicationId,
|
||||
host: generateRandomDomain({
|
||||
serverIp: admin.serverIp || "",
|
||||
projectName: application.appName,
|
||||
}),
|
||||
port: 3000,
|
||||
certificateType: "none",
|
||||
https: false,
|
||||
path: "/",
|
||||
return generateRandomDomain({
|
||||
serverIp: admin.serverIp || "",
|
||||
projectName: appName,
|
||||
});
|
||||
|
||||
return domain;
|
||||
};
|
||||
|
||||
export const generateWildcard = async (
|
||||
input: typeof apiFindDomainByApplication._type,
|
||||
) => {
|
||||
const application = await findApplicationById(input.applicationId);
|
||||
const admin = await findAdmin();
|
||||
|
||||
if (!admin.host) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "We need a host to generate a wildcard domain",
|
||||
});
|
||||
}
|
||||
const domain = await createDomain({
|
||||
applicationId: application.applicationId,
|
||||
host: generateWildcardDomain(application.appName, admin.host || ""),
|
||||
port: 3000,
|
||||
certificateType: "none",
|
||||
https: false,
|
||||
path: "/",
|
||||
});
|
||||
|
||||
return domain;
|
||||
// const application = await findApplicationById(input.applicationId);
|
||||
// const admin = await findAdmin();
|
||||
// if (!admin.host) {
|
||||
// throw new TRPCError({
|
||||
// code: "BAD_REQUEST",
|
||||
// message: "We need a host to generate a wildcard domain",
|
||||
// });
|
||||
// }
|
||||
// const domain = await createDomain({
|
||||
// applicationId: application.applicationId,
|
||||
// host: generateWildcardDomain(application.appName, admin.host || ""),
|
||||
// port: 3000,
|
||||
// certificateType: "none",
|
||||
// https: false,
|
||||
// path: "/",
|
||||
// });
|
||||
// return domain;
|
||||
};
|
||||
|
||||
export const generateWildcardDomain = (
|
||||
|
||||
Reference in New Issue
Block a user