import { isMultiSphere } from "./config.ts"; import { sphereHandle } from "./sphere.ts"; import { apiFetch } from "./api.ts"; /** * Fetch a module API endpoint with automatic sphere-scoping. * `path` should start with the module name, e.g. "/feature-requests/123". * * - Multi-sphere mode: calls `/api/s/{sphereHandle}/{path}` * - Self-hosted mode: calls `/api/{path}` */ export function moduleFetch(path: string, options?: RequestInit): Promise { const handle = sphereHandle.value; const base = isMultiSphere && handle ? `/api/s/${handle}` : "/api"; return apiFetch(`${base}${path}`, options); }