Skip to content
Fuse
Esc
navigateopen⌘Jpreview
On this page

Overview

Install the TypeScript SDK and construct a client

@folsom/fuse on npm is the TypeScript client for the Fuse control plane. It’s a typed, zero-dependency, ESM-only package that mirrors the Go SDK’s shape one to one, built on the platform fetch and web streams, so it runs on Node 18+, Deno, Bun, edge runtimes, and the browser.

Install

bun add @folsom/fuse

Requires Node 18+ (for built-in fetch and web streams) or any runtime with a standard fetch. TypeScript consumers need the web platform types in scope, either "lib": ["DOM"] (browsers/bundlers) or @types/node (Node); any project that already uses fetch has one of these.

Constructing a client

new FuseClient(options: FuseClientOptions)
interface FuseClientOptions {
  baseUrl: string;
  token?: string;
  fetch?: FetchLike;
  userAgent?: string;
  requestId?: () => string;
  timeoutMs?: number;
  headers?: Record<string, string>;
}

baseUrl is required, the orchestrator’s root (no /v1 suffix). token is sent as a bearer token and may be omitted for an orchestrator running without auth.

import { FuseClient } from "@folsom/fuse";

const client = new FuseClient({
  baseUrl: "https://fuse.example.com",
  token: process.env.FUSE_TOKEN,
});

Client options

Option Type Purpose
fetch FetchLike Custom fetch implementation. Defaults to the global fetch.
userAgent string Override the User-Agent header. Default: fuse-ts/<version>. Ignored by browsers, which control their own User-Agent.
requestId () => string Generator called once per request for X-Request-ID. An empty return value omits the header.
timeoutMs number Default per-request timeout in milliseconds. Not applied to events() streams.
headers Record<string, string> Extra default headers merged into every request.

Every service method also accepts a trailing { signal } (an AbortSignal) for per-call cancellation, combined with any client-level timeoutMs internally.

Services

Four services hang off the client, matching the Go SDK’s shape:

class FuseClient {
  readonly environments: EnvironmentsService;
  readonly snapshots: SnapshotsService;
  readonly hosts: HostsService;
  readonly apiKeys: ApiKeysService;
}
Property Page
client.environments Environments
client.hosts Hosts
client.snapshots Snapshots
client.apiKeys API keys

Request and response field names are snake_case throughout, matching the API wire format and the Go SDK, not camelCase. Only method and option names (rotateToken, taskId, and so on) follow TypeScript convention. See Quickstart for a complete working example, and Errors for how failures surface.

Was this page helpful?