UNPKG

@tutkli/jikan-ts

Version:

Node.js wrapper for the Jikan API with built-in typings.

46 lines (45 loc) 1.27 kB
import type { KyInstance } from 'ky'; import type { CacheOptions, ResponseCache } from '../config/cache'; import type { JikanResponse } from '../models'; /** * **Client Args** * * Used to pass optional configuration for logging and cache to the clients. */ export interface ClientArgs { /** * **EnableLogging** * Enables logging request responses. */ enableLogging: boolean; /** * **Cache Options** * Options for cache. */ cacheOptions: Partial<CacheOptions>; /** * **Ky Instance** * The ability to build your own ky instance if you need it */ kyInstance?: KyInstance; /** @internal Used to share cache between JikanClient sub-clients */ _cache?: ResponseCache; } /** * **Base Client** * * This client is responsible for creating a Ky Instance and the cache and logging configurations */ export declare abstract class BaseClient { private api; private cache; constructor(clientOptions?: Partial<ClientArgs>); protected getResource<T>(endpoint: string, pathParams?: { [key in string]: unknown; }, params?: { [key in string]: unknown; }): Promise<JikanResponse<T>>; private buildCacheKey; private cleanParams; private replacePathParams; }