Skip to content

Commit 4e11334

Browse files
committed
refactor(domain): simplify custom entrypoint checks in Docker and Traefik utilities
- Updated conditional checks for customEntrypoint to use a more concise syntax. - Ensured consistent handling of HTTPS configurations across domain management functions. - Improved code readability and maintainability by streamlining logic in addDomainToCompose and manageDomain functions.
1 parent 8289359 commit 4e11334

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

packages/server/src/utils/docker/domain.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export const addDomainToCompose = async (
177177
domain,
178178
domain.customEntrypoint || "web",
179179
);
180-
if (domain.customEntrypoint == null && https) {
180+
if (!domain.customEntrypoint && https) {
181181
const httpsLabels = createDomainLabels(appName, domain, "websecure");
182182
httpLabels.push(...httpsLabels);
183183
}
@@ -289,7 +289,7 @@ export const createDomainLabels = (
289289
if (stripPath && path && path !== "/") {
290290
const middlewareName = `stripprefix-${appName}-${uniqueConfigKey}`;
291291
// Only define middleware once (on web entrypoint)
292-
if (entrypoint === "web" || customEntrypoint != null) {
292+
if (entrypoint === "web" || customEntrypoint) {
293293
labels.push(
294294
`traefik.http.middlewares.${middlewareName}.stripprefix.prefixes=${path}`,
295295
);
@@ -301,7 +301,7 @@ export const createDomainLabels = (
301301
if (internalPath && internalPath !== "/" && internalPath.startsWith("/")) {
302302
const middlewareName = `addprefix-${appName}-${uniqueConfigKey}`;
303303
// Only define middleware once (on web entrypoint)
304-
if (entrypoint === "web" || customEntrypoint != null) {
304+
if (entrypoint === "web" || customEntrypoint) {
305305
labels.push(
306306
`traefik.http.middlewares.${middlewareName}.addprefix.prefix=${internalPath}`,
307307
);
@@ -317,7 +317,7 @@ export const createDomainLabels = (
317317
}
318318

319319
// Add TLS configuration for websecure
320-
if (entrypoint === "websecure" || (customEntrypoint != null && https)) {
320+
if (entrypoint === "websecure" || (customEntrypoint && https)) {
321321
if (certificateType === "letsencrypt") {
322322
labels.push(
323323
`traefik.http.routers.${routerName}.tls.certresolver=letsencrypt`,

packages/server/src/utils/traefik/domain.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const manageDomain = async (app: ApplicationNested, domain: Domain) => {
3535
domain.customEntrypoint || "web",
3636
);
3737

38-
if (domain.customEntrypoint == null && domain.https) {
38+
if (!domain.customEntrypoint && domain.https) {
3939
config.http.routers[routerNameSecure] = await createRouterConfig(
4040
app,
4141
domain,
@@ -181,7 +181,7 @@ export const createRouterConfig = async (
181181
}
182182
}
183183

184-
if (entryPoint === "websecure" || (customEntrypoint != null && https)) {
184+
if (entryPoint === "websecure" || (customEntrypoint && https)) {
185185
if (certificateType === "letsencrypt") {
186186
routerConfig.tls = { certResolver: "letsencrypt" };
187187
} else if (certificateType === "custom" && domain.customCertResolver) {

0 commit comments

Comments
 (0)