From e9588776006bfc199294660e14ced85dcfea393d Mon Sep 17 00:00:00 2001 From: dtonon Date: Mon, 15 Jun 2026 18:16:54 +0200 Subject: [PATCH] Make PUBLIC_GROUP_ID optional for full mode --- src/lib/config.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lib/config.ts b/src/lib/config.ts index e7c6615..65e8e5b 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -1,16 +1,23 @@ -import { PUBLIC_RELAY_URL, PUBLIC_GROUP_ID } from "$env/static/public"; +import { PUBLIC_RELAY_URL } from "$env/static/public"; import { env } from "$env/dynamic/public"; -// Required: a missing relay or group id is a misconfiguration, so let the -// static import fail loudly (and keep them typed as string). +// Required: a missing relay is always a misconfiguration, so let the static +// import fail loudly (and keep it typed as string). export const RELAY_URL = PUBLIC_RELAY_URL; -export const GROUP_ID = PUBLIC_GROUP_ID; // Optional: read dynamically so an unset var is undefined and falls back to its // default, instead of breaking the static-import contract at load time. export const TITLE = env.PUBLIC_TITLE ?? ""; export const MODE: "simple" | "full" = env.PUBLIC_MODE === "full" ? "full" : "simple"; + +// Required in simple mode (the single forum's group), optional in full mode +// where rooms are selected at runtime. Read dynamically so full mode can omit +// it without breaking the static-import contract. +export const GROUP_ID = env.PUBLIC_GROUP_ID ?? ""; +if (MODE === "simple" && !GROUP_ID) { + throw new Error("PUBLIC_GROUP_ID is required in simple mode"); +} export const JOINCODE_REQUIRED = env.PUBLIC_JOINCODE === "yes"; export const LABELS = (env.PUBLIC_LABELS ?? "") .split(",")