Config UX

This commit is contained in:
Râu Cao 2024-10-22 19:41:49 +02:00
parent 453a0f14d3
commit f15e845825
Signed by: raucao
GPG Key ID: 37036C356E56CC51

View File

@ -10,11 +10,10 @@ let staticUsers;
try {
const yamlContent = await Deno.readTextFile(`${dirname}/users.yaml`);
staticUsers = parse(yamlContent);
log("Static user config:", "blue");
log(Deno.inspect(staticUsers), "blue");
log(`Serving content for ${Object.keys(staticUsers).length} pubkeys from users.yaml`, "blue");
} catch {
staticUsers = {};
log(`Could not find or parse a "users.yaml" config`, "yellow");
log(`Could not find or parse a users.yaml config`, "yellow");
}
const relay_urls = Deno.env.get("RELAY_URLS")?.split(",");
@ -33,6 +32,22 @@ const config = {
},
};
log(`LDAP enabled: ${config.ldapEnabled}`, "blue");
if (config.ldapEnabled && config.ldap.url) {
log(`Serving content for pubkeys from ${config.ldap.url}`, "blue");
} else {
log(`LDAP not enabled`, "blue");
}
if (Object.keys(staticUsers).length === 0 && !config.ldapEnabled) {
log(`Neither static users nor LDAP configured. Nothing to serve.`);
Deno.exit(1);
}
if (config.relay_urls?.length > 0) {
log(`Relays: ${config.relay_urls.join(", ")}`, "green");
} else {
log(`No relays configured. Please add at least one relay to RELAY_URLS.`);
Deno.exit(1);
}
export default config;