Files
it-tools/src/tools-settings.ts
T
Sebastian DanielssonandClaude Opus 5.5 4a80283786 feat(settings): add an offline mode that hides internet-only tools
"offline": true in tools-settings.json hides tools that need internet
access (menus and routes). Tools declare it with requiresInternet, either
always or unless an intranet mirror is configured. The settings helper
lives in a module without top-level await so eagerly loaded tool
index.ts files can use it without delaying app boot.

Refs sharevb/it-tools#571

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-25 18:51:17 +01:00

18 lines
937 B
TypeScript

import { appBaseUrl as base } from '@/utils/base-url';
import type { ToolsSettings } from '@/utils/tools-settings';
export { type ToolsSettings, getToolsSettingString } from '@/utils/tools-settings';
// Optional per-deployment settings. Lives in its own top-level-await module so the
// fetch runs concurrently with the config fetches in src/tools/index.ts (sibling async
// module subgraphs evaluate in parallel) instead of serially after them.
export const toolsSettings: ToolsSettings = await fetch(`${base}tools-settings.json`)
.then((response) => (response.ok ? (response.json() as Promise<ToolsSettings>) : {}))
.catch(() => ({}));
/**
* `"offline": true` in tools-settings.json marks a deployment without internet access (an air-gapped intranet).
* Tools that only work with internet are hidden, and tools with a bundled or mirrored fallback switch to it.
*/
export const isOfflineMode = toolsSettings.offline === true;