Exosphere is a set of small, modular, self-hostable community tools built on the AT Protocol. app.exosphere.site
at main 16 lines 619 B view raw
1import { isMultiSphere } from "./config.ts"; 2import { sphereHandle } from "./sphere.ts"; 3import { apiFetch } from "./api.ts"; 4 5/** 6 * Fetch a module API endpoint with automatic sphere-scoping. 7 * `path` should start with the module name, e.g. "/feature-requests/123". 8 * 9 * - Multi-sphere mode: calls `/api/s/{sphereHandle}/{path}` 10 * - Self-hosted mode: calls `/api/{path}` 11 */ 12export function moduleFetch<T>(path: string, options?: RequestInit): Promise<T> { 13 const handle = sphereHandle.value; 14 const base = isMultiSphere && handle ? `/api/s/${handle}` : "/api"; 15 return apiFetch<T>(`${base}${path}`, options); 16}