()
| 15 | * Must be called before any API operations |
| 16 | */ |
| 17 | export async function initializeApiUrl(): Promise<void> { |
| 18 | // 1. Environment variable has highest priority (allows temporary override) |
| 19 | if (process.env.HAPI_API_URL) { |
| 20 | return |
| 21 | } |
| 22 | |
| 23 | // 2. Read from settings file (new name first, then legacy) |
| 24 | const settings = await readSettings() |
| 25 | if (settings.apiUrl) { |
| 26 | configuration._setApiUrl(settings.apiUrl) |
| 27 | return |
| 28 | } |
| 29 | if (settings.serverUrl) { |
| 30 | // Migrate from legacy field name |
| 31 | configuration._setApiUrl(settings.serverUrl) |
| 32 | return |
| 33 | } |
| 34 | |
| 35 | // 3. Default value already set in configuration constructor |
| 36 | } |
no test coverage detected