From f15e84582552b15d8002c7c4377c32438a00828a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Tue, 22 Oct 2024 19:41:49 +0200 Subject: [PATCH] Config UX --- config.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/config.ts b/config.ts index 5a151cc..f4f8aed 100644 --- a/config.ts +++ b/config.ts @@ -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;