( envKey: string, fallback: string, isProd: boolean, severity: "fatal" | "info" = "fatal", )
| 163 | } |
| 164 | |
| 165 | function readUrl( |
| 166 | envKey: string, |
| 167 | fallback: string, |
| 168 | isProd: boolean, |
| 169 | severity: "fatal" | "info" = "fatal", |
| 170 | ): string { |
| 171 | const value = readEnvPair(envKey); |
| 172 | if (value !== undefined) return value.replace(/\/+$/, ""); |
| 173 | if (isProd) { |
| 174 | if (severity === "fatal") { |
| 175 | // eslint-disable-next-line no-console |
| 176 | console.error( |
| 177 | `[shell-docs runtime-config] FATAL-CONFIG: ${envKey} is unset in a production deploy; ` + |
| 178 | `using fallback ${fallback}. Set the env var on the Railway service.`, |
| 179 | ); |
| 180 | } else { |
| 181 | // warn-level: legitimate prod default exists; absence is |
| 182 | // recoverable so we log but do not raise the FATAL-CONFIG flag |
| 183 | // that triggers ops alerts. console.warn (not console.info) so |
| 184 | // the line clears prod log-aggregation thresholds and stays |
| 185 | // visible to operators. |
| 186 | // eslint-disable-next-line no-console |
| 187 | console.warn( |
| 188 | `[shell-docs runtime-config] ${envKey} unset; using prod default ${fallback}`, |
| 189 | ); |
| 190 | } |
| 191 | } else { |
| 192 | // eslint-disable-next-line no-console |
| 193 | console.warn( |
| 194 | `[shell-docs runtime-config] ${envKey} unset; using dev fallback ${fallback}`, |
| 195 | ); |
| 196 | } |
| 197 | return fallback.replace(/\/+$/, ""); |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Read an analytics key. Empty/missing values are returned as the empty |
no test coverage detected
searching dependent graphs…