@tragedy-labs/sprite
Version:
A TypeScript driver for ArcadeDB
33 lines (32 loc) • 1.29 kB
TypeScript
import { SpriteHeadersInit } from './SpriteHeaders.js';
export interface DatabaseSession {
address: string;
auth: string;
databaseName: string;
headers: HeadersInit;
}
export interface SpriteRequestInit extends RequestInit {
headers: SpriteHeadersInit;
}
/**
* Utility class for making HTTP requests to the ArcadeDB server.
*/
declare class HttpClient {
/**
* Make a request to the server.
* @param session The `SpriteDatabaseSession` to target in the request.
* @param relativeEndpoint The relative {@link https://docs.arcadedb.com/#HTTP-API endpoint} for the request, if it's a database endpoint it includes the database name. Any composition must be handled by the calling method.
* @param requestInit A `fetch` `RequestInit` object: `{ methods, headers, body }`.
* @returns
*/
static request(endpoint: string, requestInit: SpriteRequestInit): Promise<Response>;
/**
* Handles error handling of the response, or returns the response if nothing went wrong.
* @param response
* @returns
* @throws If there is a {@link https://httpstatuses.io/403 `403`} or {@link https://httpstatuses.io/404 `404`} error.
* @see {@link ArcadeFetchError}
*/
private static handleResponse;
}
export { HttpClient };