@wristband/express-auth
Version:
SDK for integrating your ExpressJS application with Wristband. Handles user authentication, session management, and token management.
33 lines (32 loc) • 1.29 kB
TypeScript
/**
* Thin fetch-based HTTP client for the Wristband API.
*
* Wraps native `fetch` (Node 20+) with a base URL, default headers, and
* structured error handling. Non-2xx responses are thrown as {@link FetchError}
* instances carrying both the raw `Response` and the parsed body.
*/
export declare class WristbandApiClient {
private readonly baseURL;
private readonly defaultHeaders;
constructor(wristbandApplicationVanityDomain: string);
private request;
/**
* Performs a GET request to the given API endpoint.
*
* @param endpoint - Path relative to the base URL.
* @param headers - Optional additional or override headers.
* @returns The parsed JSON response body.
* @throws {FetchError} On non-2xx responses.
*/
get<T>(endpoint: string, headers?: HeadersInit): Promise<T>;
/**
* Performs a POST request to the given API endpoint.
*
* @param endpoint - Path relative to the base URL.
* @param body - Request body (typically a form-encoded string).
* @param headers - Optional additional or override headers.
* @returns The parsed JSON response body.
* @throws {FetchError} On non-2xx responses.
*/
post<T>(endpoint: string, body: any, headers?: HeadersInit): Promise<T>;
}