check for user before getting orgs, create default config

This commit is contained in:
Milo Schwartz
2024-10-22 23:58:00 -04:00
parent 6d9731f071
commit 717aa09daa
6 changed files with 49 additions and 29 deletions

View File

@@ -84,6 +84,25 @@ if (fs.existsSync(configFilePath1)) {
} else if (fs.existsSync(configFilePath2)) {
environment = loadConfig(configFilePath2);
}
if (!environment) {
const exampleConfigPath = path.join("config.example.yml");
if (fs.existsSync(exampleConfigPath)) {
try {
const exampleConfigContent = fs.readFileSync(exampleConfigPath, "utf8");
fs.writeFileSync(configFilePath1, exampleConfigContent, "utf8");
environment = loadConfig(configFilePath1);
} catch (error) {
if (error instanceof Error) {
throw new Error(
`Error creating configuration file from example: ${error.message}`,
);
}
throw error;
}
} else {
throw new Error("No configuration file found and no example configuration available");
}
}
if (!environment) {
throw new Error("No configuration file found");

View File

@@ -33,12 +33,6 @@ export function buildTraefikConfig(
const tls = {
certResolver: config.traefik.cert_resolver,
// domains: [ // TODO: figure out if this is neccessary
// {
// main: baseDomain,
// sans: ["*." + baseDomain],
// },
// ],
};
const http: any = {
@@ -59,8 +53,8 @@ export function buildTraefikConfig(
},
};
for (const target of targets) {
const routerName = `router-${target.targetId}`;
const serviceName = `service-${target.targetId}`;
const routerName = `${target.targetId}-router`;
const serviceName = `${target.targetId}-service`;
http.routers![routerName] = {
entryPoints: [target.ssl ? config.traefik.https_entrypoint : config.traefik.https_entrypoint],