Skip to content

ReelVaultClient ​

ts
import { ReelVaultClient } from "@reelvault/sdk/client";

const api = new ReelVaultClient({
  baseUrl: "http://localhost:3030",
  credentials: "include",
});

One instance wraps the whole API. All 25 resource clients share a single transport, which is what makes in-flight GET deduplication, caching, retries and token refresh behave consistently across the surface.

ClientConfig ​

OptionTypeDefaultDescription
baseUrlstring | (() => string)— (required)API origin. Strings are trimmed of a trailing slash; a function is evaluated per request.
fetcher(url, options) => Promise<Response>global fetchCustom fetch implementation (test seams, proxies).
headersHeadersInit | Record<string, string> | Map<string, string>—Default headers merged into every request.
accessTokenstring—Sent as Authorization: Bearer ….
onTokenExpired() => string | Promise<string>—Called after a 401; returns a replacement token.
requestInterceptorsRequestInterceptor[][]Run before each request; may rewrite URL/options.
responseInterceptorsResponseInterceptor[][]Run after each response.
enableRetrybooleantrueRetry transient failures.
maxRetriesnumber3Retry limit per request.
timeoutnumber30000Per-request timeout, in ms.
credentialsRequestCredentials"same-origin"Use "include" for cross-origin cookie sessions.
enableCachebooleanfalseTTL cache for successful GETs.
cacheTtlMsnumber5000Cache time-to-live, in ms.
maxTokenRefreshAttemptsnumber1How many 401-triggered refreshes one request may use.

Interceptor types ​

ts
type RequestInterceptor = (
  url: string,
  options: RequestInit,
) => { url: string; options: RequestInit } | Promise<{ url: string; options: RequestInit }>;

type ResponseInterceptor = (response: Response) => Response | Promise<Response>;

Instance methods ​

MemberSignatureDescription
setAccessToken(token: string | undefined) => voidSwap the bearer token at runtime.
getAccessToken() => string | undefinedRead the current bearer token.
clearCache() => voidDrop the shared GET cache and in-flight dedupe state.

Resource clients ​

GroupProperties
Administrationadmin
User & profileauth, setup, profiles, notifications, me
Library & fileslibraries, media
Metadatametadata, collections, companies, genres, keywords, people, images
Video contentseasons, episodes
Browse & playbackdiscover, playbackSessions, downloads, subtitles, providers, plugins, events
Utilitieshealth

Method signatures for every resource are in Client resources.

See also ​

Released under the GNU GPL v3.