node-hitomi
Version:
Hitomi.la API for Node.js
75 lines (72 loc) • 1.99 kB
TypeScript
import { GalleryManager } from './managers/gallery.js';
import { TagManager } from './managers/tag.js';
import { TransportFunction, OnRequestFunction, ComputeHashFunction } from './platform/shared.js';
/**
* Options for creating a hitomi client.
*
* @template T The platform-specific request options type.
* @see {@link Hitomi}
*/
interface HitomiOptions<T = any> {
/**
* A custom HTTPS agent for connection pooling.
*
* @default new Agent({ keepAlive: true })
* @deprecated Use {@link onRequest} instead. This option takes precedence over `onRequest` when set. Will be removed in v10.
*/
agent?: unknown;
/**
* A custom transport function for making HTTPS requests.
*/
transport?: TransportFunction<T>;
/**
* A hook function invoked before each HTTP request.
*/
onRequest?: OnRequestFunction<T>;
/**
* A custom function for computing SHA-256 hashes.
*/
computeHash?: ComputeHashFunction;
/**
* Maximum age in milliseconds, before the cached index version is refreshed.
*
* @default 600000
*/
indexMaximumAge?: number;
/**
* Maximum age in milliseconds, before the cached image URL context is refreshed.
*
* @default 3600000
*/
imageContextMaximumAge?: number;
}
/**
* A client for interacting with the Hitomi API.
*/
declare class Hitomi {
/**
* A manager for retrieving and listing galleries.
*
* @type {GalleryManager}
* @readonly
* @see {@link GalleryManager}
*/
readonly galleries: GalleryManager;
/**
* A manager for creating, parsing, searching, and listing tags.
*
* @type {TagManager}
* @readonly
* @see {@link TagManager}
*/
readonly tags: TagManager;
/**
* Creates a new Hitomi client.
*
* @param {HitomiOptions} [options] The configuration options for the client.
* @throws {HitomiError} If `options.indexMaximumAge` or `options.imageContextMaximumAge` is provided as a negative integer.
*/
constructor(options?: HitomiOptions);
}
export { Hitomi };
export type { HitomiOptions };