()
| 375 | }; |
| 376 | |
| 377 | export const createDefaultTraefikConfig = () => { |
| 378 | const { MAIN_TRAEFIK_PATH, DYNAMIC_TRAEFIK_PATH } = paths(); |
| 379 | const mainConfig = path.join(MAIN_TRAEFIK_PATH, "traefik.yml"); |
| 380 | const acmeJsonPath = path.join(DYNAMIC_TRAEFIK_PATH, "acme.json"); |
| 381 | |
| 382 | if (existsSync(acmeJsonPath)) { |
| 383 | chmodSync(acmeJsonPath, "600"); |
| 384 | } |
| 385 | |
| 386 | // Create the traefik directory first |
| 387 | mkdirSync(MAIN_TRAEFIK_PATH, { recursive: true }); |
| 388 | |
| 389 | // Check if traefik.yml exists and handle the case where it might be a directory |
| 390 | if (existsSync(mainConfig)) { |
| 391 | const stats = statSync(mainConfig); |
| 392 | if (stats.isDirectory()) { |
| 393 | // If traefik.yml is a directory, remove it |
| 394 | console.log("Found traefik.yml as directory, removing it..."); |
| 395 | rmSync(mainConfig, { recursive: true, force: true }); |
| 396 | } else if (stats.isFile()) { |
| 397 | console.log("Main config already exists"); |
| 398 | return; |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | const yamlStr = getDefaultTraefikConfig(); |
| 403 | writeFileSync(mainConfig, yamlStr, "utf8"); |
| 404 | console.log("Traefik config created successfully"); |
| 405 | }; |
| 406 | |
| 407 | export const getDefaultMiddlewares = () => { |
| 408 | const defaultMiddlewares = { |
no test coverage detected