@tutkli/jikan-ts 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +16 -0
- package/.eslintignore +17 -0
- package/.eslintrc.json +27 -0
- package/.prettierrc.json +8 -0
- package/CHANGELOG.md +30 -0
- package/LICENSE +21 -0
- package/README.md +64 -0
- package/dist/index.d.ts +671 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +584 -0
- package/dist/index.js.map +1 -0
- package/jest.config.js +25 -0
- package/package.json +60 -0
- package/src/__tests__/anime-client.spec.ts +33 -0
- package/src/__tests__/manga-client.spec.ts +33 -0
- package/src/__tests__/top-client.spec.ts +33 -0
- package/src/clients/anime.client.ts +233 -0
- package/src/clients/base.client.ts +82 -0
- package/src/clients/index.ts +4 -0
- package/src/clients/jikan.client.ts +28 -0
- package/src/clients/manga.client.ts +142 -0
- package/src/clients/top.client.ts +52 -0
- package/src/config/cache.config.ts +8 -0
- package/src/config/index.ts +2 -0
- package/src/config/logger.config.ts +25 -0
- package/src/constants/base.constant.ts +3 -0
- package/src/constants/endpoints.constant.ts +29 -0
- package/src/constants/index.ts +2 -0
- package/src/index.ts +4 -0
- package/src/models/Anime/anime-character.model.ts +11 -0
- package/src/models/Anime/anime-episode.model.ts +12 -0
- package/src/models/Anime/anime-picture.model.ts +5 -0
- package/src/models/Anime/anime-staff.model.ts +6 -0
- package/src/models/Anime/anime-statistics.model.ts +6 -0
- package/src/models/Anime/anime-video.model.ts +38 -0
- package/src/models/Anime/anime.model.ts +95 -0
- package/src/models/Anime/index.ts +7 -0
- package/src/models/Common/character.model.ts +18 -0
- package/src/models/Common/image.model.ts +12 -0
- package/src/models/Common/index.ts +6 -0
- package/src/models/Common/person.model.ts +8 -0
- package/src/models/Common/recommendation.model.ts +12 -0
- package/src/models/Common/resource.model.ts +31 -0
- package/src/models/Common/statistics.model.ts +13 -0
- package/src/models/Manga/index.ts +2 -0
- package/src/models/Manga/manga-statistics.model.ts +6 -0
- package/src/models/Manga/manga.model.ts +58 -0
- package/src/models/Params/index.ts +2 -0
- package/src/models/Params/search-params.model.ts +72 -0
- package/src/models/Params/top-params.model.ts +41 -0
- package/src/models/Response/index.ts +1 -0
- package/src/models/Response/response.model.ts +21 -0
- package/src/models/index.ts +4 -0
- package/tsconfig.eslint.json +5 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEAA;;;;;;AEAA,IAAO;UAAK,OAAO;IAAP,QACV,UAAO;GADG,4CAAA;;ADAZ;;;;;;AEAA,IAAO;UAAK,cAAc;IAAd,eACV,iBAAc;IADJ,eAEV,mBAAgB;IAFN,eAGV,eAAY;IAHF,eAIV,qBAAkB;IAJR,eAKV,gBAAa;IALH,eAMV,mBAAgB;IANN,eAOV,sBAAmB;IAPT,eAQV,iBAAc;IARJ,eASV,yBAAsB;IATZ,eAUV,mBAAgB;IAVN,eAWV,qBAAkB;IAXR,eAYV,0BAAuB;GAZb,8CAAA;IAeL;UAAK,cAAc;IAAd,eACV,iBAAc;IADJ,eAEV,mBAAgB;IAFN,eAGV,eAAY;IAHF,eAIV,qBAAkB;IAJR,eAKV,mBAAgB;IALN,eAMV,qBAAkB;IANR,eAOV,0BAAuB;GAPb,8CAAA;IAUL;UAAK,YAAY;IAAZ,aACV,cAAW;IADD,aAEV,cAAW;GAFD,8CAAA;;;;;;;;;;;AEzBZ;AAEO,MAAM,4CAAwB;IACnC,SAAS,CAAA,GAAA,+CAAiB;IAC1B,aAAa,CAAA,GAAA,gDAAkB;IAC/B,mBAAmB,CAAA,GAAA,qDAAuB;IAC1C,OAAO;AACT;;ADPA;;;;;;;;AEAA;AAIO,MAAM,4CAAe,CAAC,UAAuD,CAAA,GAAA,gBAAG,EAAE;AAElF,MAAM,4CAAgB,CAAC,QAA4B,SAAuC;IAC/F,OAAO,IAAI,CAAC,CAAC,mBAAmB,EAAE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EV,QAAA;IAFU,YAGV,UAAA;IAHU,YAIV,SAAA;IAJU,YAKV,OAAA;IALU,YAMV,QAAA;GANU,8CAAA;IASL;UAAK,WAAW;IAAX,YACV,YAAA;IADU,YAEV,YAAA;IAFU,YAGV,UAAA;IAHU,YAIV,YAAA;GAJU,8CAAA;;ADzFZ;;;;;;;;;;;;;;;;;;;;;;;;;;;ADAA;;;;ASAA;;;;;;;AGAA,IAcO;UAAK,aAAa;IAAb,cACV,UAAO;IADG,cAEV,gBAAa;GAFH,8CAAA;;;;;;;;;;;;;;;;;;;;;;;;;AKdZ,IAyCO;UAAK,SAAS;IAAT,UACV,WAAQ;IADE,UAEV,WAAQ;IAFE,UAGV,gBAAa;IAHH,UAIV,aAAU;IAJA,UAKV,YAAS;IALC,UAMV,YAAS;IANC,UAOV,YAAS;GAPC,8CAAA;IAUL;UAAK,WAAW;IAAX,YACV,gBAAa;IADH,YAEV,cAAW;IAFD,YAGV,YAAS;IAHC,YAIV,kBAAe;IAJL,YAKV,cAAW;GALD,8CAAA;;ADnDZ;;;;;;;;;;;AGAA;;;;;;;;;","sources":["src/index.ts","src/clients/index.ts","src/clients/base.client.ts","src/constants/index.ts","src/constants/base.constant.ts","src/constants/endpoints.constant.ts","src/config/index.ts","src/config/cache.config.ts","src/config/logger.config.ts","src/clients/anime.client.ts","src/clients/manga.client.ts","src/clients/jikan.client.ts","src/clients/top.client.ts","src/models/index.ts","src/models/Anime/index.ts","src/models/Anime/anime.model.ts","src/models/Anime/anime-character.model.ts","src/models/Anime/anime-staff.model.ts","src/models/Anime/anime-episode.model.ts","src/models/Anime/anime-video.model.ts","src/models/Anime/anime-picture.model.ts","src/models/Anime/anime-statistics.model.ts","src/models/Common/index.ts","src/models/Common/resource.model.ts","src/models/Common/image.model.ts","src/models/Common/character.model.ts","src/models/Common/person.model.ts","src/models/Common/recommendation.model.ts","src/models/Common/statistics.model.ts","src/models/Manga/index.ts","src/models/Manga/manga.model.ts","src/models/Manga/manga-statistics.model.ts","src/models/Response/index.ts","src/models/Response/response.model.ts"],"sourcesContent":["export * from './clients';\r\nexport * from './config';\r\nexport * from './constants';\r\nexport * from './models';\r\n","export * from './base.client';\r\nexport * from './anime.client';\r\nexport * from './manga.client';\r\nexport * from './jikan.client';\r\n","import { Logger, LoggerOptions } from 'pino';\r\nimport {\r\n AxiosCacheInstance,\r\n CacheAxiosResponse,\r\n CacheOptions,\r\n CacheRequestConfig,\r\n setupCache,\r\n} from 'axios-cache-interceptor';\r\nimport axios, { AxiosError } from 'axios';\r\nimport { BaseURL } from '../constants';\r\nimport {\r\n createLogger,\r\n DEFAULT_CACHE_OPTIONS,\r\n handleRequest,\r\n handleRequestError,\r\n handleResponse,\r\n handleResponseError,\r\n} from '../config';\r\n\r\n/**\r\n * **Client Args**\r\n * Used to pass optional configuration for logging and cache to the clients.\r\n */\r\nexport interface ClientArgs {\r\n /**\r\n * **Logger Options**\r\n * Options for the client logger.\r\n * @see https://getpino.io/#/docs/api?id=options\r\n */\r\n logOptions?: LoggerOptions;\r\n /**\r\n * **Axios Cache Options**\r\n * Options for cache.\r\n * @see https://axios-cache-interceptor.js.org/#/pages/configuration\r\n */\r\n cacheOptions?: CacheOptions;\r\n /**\r\n * **Base URL**\r\n * Location of the JikanAPI. Leave empty to use the official JikanAPI instance.\r\n */\r\n baseURL?: string;\r\n}\r\n\r\n/**\r\n * **Base Client** This client is responsible for creating an Axios Instance and the cache and logging configurations\r\n */\r\nexport abstract class BaseClient {\r\n public api: AxiosCacheInstance;\r\n public logger: Logger;\r\n\r\n constructor(clientOptions?: ClientArgs) {\r\n this.api = setupCache(\r\n axios.create({\r\n baseURL: clientOptions?.baseURL ?? BaseURL.REST,\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n }),\r\n {\r\n storage: clientOptions?.cacheOptions?.storage ?? DEFAULT_CACHE_OPTIONS.storage,\r\n generateKey: clientOptions?.cacheOptions?.generateKey ?? DEFAULT_CACHE_OPTIONS.generateKey,\r\n headerInterpreter: clientOptions?.cacheOptions?.headerInterpreter ?? DEFAULT_CACHE_OPTIONS.headerInterpreter,\r\n debug: clientOptions?.cacheOptions?.debug ?? DEFAULT_CACHE_OPTIONS.debug,\r\n }\r\n );\r\n\r\n this.logger = createLogger({\r\n enabled: !(clientOptions?.logOptions?.enabled === undefined || clientOptions?.logOptions.enabled === false),\r\n ...clientOptions?.logOptions,\r\n });\r\n\r\n this.api.interceptors.request.use(\r\n (config: CacheRequestConfig) => handleRequest(config, this.logger),\r\n (error: AxiosError<string>) => handleRequestError(error, this.logger)\r\n );\r\n\r\n this.api.interceptors.response.use(\r\n (response: CacheAxiosResponse) => handleResponse(response, this.logger),\r\n (error: AxiosError<string>) => handleResponseError(error, this.logger)\r\n );\r\n }\r\n}\r\n","export * from './base.constant';\r\nexport * from './endpoints.constant';\r\n","export enum BaseURL {\r\n REST = 'https://api.jikan.moe/v4',\r\n}\r\n","export enum AnimeEndpoints {\n AnimeSearch = '/anime',\n AnimeFullById = '/anime/{id}/full',\n AnimeById = '/anime/{id}',\n AnimeCharacters = '/anime/{id}/characters',\n AnimeStaff = '/anime/{id}/staff',\n AnimeEpisodes = '/anime/{id}/episodes',\n AnimeEpisodeById = '/anime/{id}/episodes/{episode}',\n AnimeVideos = '/anime/{id}/videos',\n AnimeVideosEpisodes = '/anime/{id}/videos/episodes',\n AnimePictures = '/anime/{id}/pictures',\n AnimeStatistics = '/anime/{id}/statistics',\n AnimeRecommendations = '/anime/{id}/recommendations',\n}\n\nexport enum MangaEndpoints {\n MangaSearch = '/manga',\n MangaFullById = '/manga/{id}/full',\n MangaById = '/manga/{id}',\n MangaCharacters = '/manga/{id}/characters',\n MangaPictures = '/manga/{id}/pictures',\n MangaStatistics = '/manga/{id}/statistics',\n MangaRecommendations = '/manga/{id}/recommendations',\n}\n\nexport enum TopEndpoints {\n TopAnime = '/top/anime',\n TopManga = '/top/manga',\n}\n","export * from './cache.config';\r\nexport * from './logger.config';\r\n","import { buildMemoryStorage, defaultHeaderInterpreter, defaultKeyGenerator } from 'axios-cache-interceptor';\r\n\r\nexport const DEFAULT_CACHE_OPTIONS = {\r\n storage: buildMemoryStorage(),\r\n generateKey: defaultKeyGenerator,\r\n headerInterpreter: defaultHeaderInterpreter,\r\n debug: undefined,\r\n};\r\n","import { DestinationStream, Logger, LoggerOptions, pino } from 'pino';\r\nimport { AxiosError } from 'axios';\r\nimport { CacheAxiosResponse, CacheRequestConfig } from 'axios-cache-interceptor';\r\n\r\nexport const createLogger = (options: LoggerOptions | DestinationStream): Logger => pino(options);\r\n\r\nexport const handleRequest = (config: CacheRequestConfig, logger: Logger): CacheRequestConfig => {\r\n logger.info(`[ Request Config ] ${config.method?.toUpperCase() || ''} | ${config.url || ''}`);\r\n return config;\r\n};\r\n\r\nexport const handleRequestError = (error: AxiosError, logger: Logger): Promise<AxiosError> => {\r\n logger.error(`[ Request Error] CODE ${error.code || 'UNKNOWN'} | ${error.message}`);\r\n throw error;\r\n};\r\n\r\nexport const handleResponse = (response: CacheAxiosResponse, logger: Logger): CacheAxiosResponse => {\r\n logger.info(response.data);\r\n return response;\r\n};\r\n\r\nexport const handleResponseError = (error: AxiosError, logger: Logger): Promise<AxiosError> => {\r\n logger.error(`[ Response Error ] CODE ${error.code || 'UNKNOWN'} | ${error.message}`);\r\n throw error;\r\n};\r\n","import { BaseClient, ClientArgs } from './base.client';\nimport { AnimeEndpoints } from '../constants';\nimport { CacheAxiosResponse } from 'axios-cache-interceptor';\nimport { AxiosError } from 'axios';\nimport {\n Anime,\n AnimeCharacter,\n AnimeEpisode,\n AnimePicture,\n AnimeStaff,\n AnimeStatistics,\n AnimeVideo,\n AnimeVideoEpisode,\n JikanResponse,\n JikanUniqueResponse,\n Recommendation,\n} from '../models';\nimport { AnimeSearchParams } from '../models/Params';\n\n/**\n * **Anime Client**\n *\n * Client used to access the Anime Endpoints:\n * - [AnimeSearch](https://docs.api.jikan.moe/#tag/anime)\n * - [AnimeFullById](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeFullById)\n * - [AnimeById](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeById)\n * - [AnimeCharacters](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeCharacters)\n * - [AnimeStaff](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeStaff)\n * - [AnimeEpisodes](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeEpisodes)\n * - [AnimeEpisodeById](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeEpisodeById)\n * - [AnimeVideos](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeVideos)\n * - [AnimeVideosEpisodes](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeVideosEpisodes)\n * - [AnimePictures](https://docs.api.jikan.moe/#tag/anime/operation/getAnimePictures)\n * - [AnimeStatistics](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeStatistics)\n * - [AnimeRecommendations](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeRecommendations)\n *\n * See also: [JikanAPI](https://docs.api.jikan.moe/)\n */\nexport class AnimeClient extends BaseClient {\n /**\n * @argument clientOptions Options for the client.\n */\n constructor(clientOptions?: ClientArgs) {\n super(clientOptions);\n }\n\n /**\n * Get all the filtered Animes. Returns all the Animes if no filters are given.\n * @param searchParams Filter parameters\n * @returns A JikanResponse with Anime data\n */\n public async getAnimeSearch(searchParams?: AnimeSearchParams): Promise<JikanResponse<Anime>> {\n return new Promise<JikanResponse<Anime>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeSearch}`;\n this.api\n .get<JikanResponse<Anime>>(endpoint, { params: searchParams })\n .then((response: CacheAxiosResponse<JikanResponse<Anime>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get a complete Anime resource data\n * @param mal_id The Anime ID\n * @returns A JikanUniqueResponse with Anime data\n */\n public async getAnimeFullById(mal_id: number): Promise<JikanUniqueResponse<Anime>> {\n return new Promise<JikanUniqueResponse<Anime>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeFullById.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanUniqueResponse<Anime>>(endpoint)\n .then((response: CacheAxiosResponse<JikanUniqueResponse<Anime>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Anime resource data\n * @param mal_id The Anime ID\n * @returns A JikanUniqueResponse with Anime data\n */\n public async getAnimeById(mal_id: number): Promise<JikanUniqueResponse<Anime>> {\n return new Promise<JikanUniqueResponse<Anime>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeById.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanUniqueResponse<Anime>>(endpoint)\n .then((response: CacheAxiosResponse<JikanUniqueResponse<Anime>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Characters of a specific Anime\n * @param mal_id The Anime ID\n * @returns A JikanResponse with AnimeCharacter data\n */\n public async getAnimeCharacters(mal_id: number): Promise<JikanResponse<AnimeCharacter>> {\n return new Promise<JikanResponse<AnimeCharacter>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeCharacters.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanResponse<AnimeCharacter>>(endpoint)\n .then((response: CacheAxiosResponse<JikanResponse<AnimeCharacter>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Staff of a specific Anime\n * @param mal_id The Anime ID\n * @returns A JikanResponse with AnimeStaff data\n */\n public async getAnimeStaff(mal_id: number): Promise<JikanResponse<AnimeStaff>> {\n return new Promise<JikanResponse<AnimeStaff>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeStaff.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanResponse<AnimeStaff>>(endpoint)\n .then((response: CacheAxiosResponse<JikanResponse<AnimeStaff>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get a list of all the episodes of a specific Anime\n * @param mal_id The Anime ID\n * @returns A JikanResponse with AnimeEpisode data\n */\n public async getAnimeEpisodes(mal_id: number): Promise<JikanResponse<AnimeEpisode>> {\n return new Promise<JikanResponse<AnimeEpisode>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeEpisodes.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanResponse<AnimeEpisode>>(endpoint)\n .then((response: CacheAxiosResponse<JikanResponse<AnimeEpisode>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get a single Episode of a specific Anime by its ID\n * @param anime_mal_id The Anime ID\n * @param episode_mal_id The Episode ID\n * @returns A JikanUniqueResponse with AnimeEpisode data\n */\n public async getAnimeEpisodeById(\n anime_mal_id: number,\n episode_mal_id: number\n ): Promise<JikanUniqueResponse<AnimeEpisode>> {\n return new Promise<JikanUniqueResponse<AnimeEpisode>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeEpisodeById.replace('{id}', String(anime_mal_id)).replace(\n '{episode}',\n String(episode_mal_id)\n )}`;\n this.api\n .get<JikanUniqueResponse<AnimeEpisode>>(endpoint)\n .then((response: CacheAxiosResponse<JikanUniqueResponse<AnimeEpisode>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Videos related to a specific Anime\n * @param mal_id The Anime ID\n * @returns A JikanUniqueResponse with AnimeVideo data\n */\n public async getAnimeVideos(mal_id: number): Promise<JikanUniqueResponse<AnimeVideo>> {\n return new Promise<JikanUniqueResponse<AnimeVideo>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeVideos.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanUniqueResponse<AnimeVideo>>(endpoint)\n .then((response: CacheAxiosResponse<JikanUniqueResponse<AnimeVideo>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Episode Videos related to a specific Anime\n * @param mal_id The Anime ID\n * @returns A JikanResponse with AnimeVideoEpisode data\n */\n public async getAnimeVideosEpisode(mal_id: number): Promise<JikanResponse<AnimeVideoEpisode>> {\n return new Promise<JikanResponse<AnimeVideoEpisode>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeVideosEpisodes.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanResponse<AnimeVideoEpisode>>(endpoint)\n .then((response: CacheAxiosResponse<JikanResponse<AnimeVideoEpisode>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Pictures related to a specific Anime\n * @param mal_id The Anime ID\n * @returns A JikanResponse with AnimePicture data\n */\n public async getAnimePictures(mal_id: number): Promise<JikanResponse<AnimePicture>> {\n return new Promise<JikanResponse<AnimePicture>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimePictures.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanResponse<AnimePicture>>(endpoint)\n .then((response: CacheAxiosResponse<JikanResponse<AnimePicture>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Statistics related to a specific Anime\n * @param mal_id The Anime ID\n * @returns A JikanUniqueResponse with AnimeStatistics data\n */\n public async getAnimeStatistics(mal_id: number): Promise<JikanUniqueResponse<AnimeStatistics>> {\n return new Promise<JikanUniqueResponse<AnimeStatistics>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeStatistics.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanUniqueResponse<AnimeStatistics>>(endpoint)\n .then((response: CacheAxiosResponse<JikanUniqueResponse<AnimeStatistics>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Recommendations related to a specific Anime\n * @param mal_id The Anime ID\n * @returns A JikanResponse with Recommendation data\n */\n public async getAnimeRecommendation(mal_id: number): Promise<JikanResponse<Recommendation>> {\n return new Promise<JikanResponse<Recommendation>>((resolve, reject) => {\n const endpoint = `${AnimeEndpoints.AnimeRecommendations.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanResponse<Recommendation>>(endpoint)\n .then((response: CacheAxiosResponse<JikanResponse<Recommendation>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n}\n","import { BaseClient, ClientArgs } from './base.client';\nimport { MangaEndpoints } from '../constants';\nimport { CacheAxiosResponse } from 'axios-cache-interceptor';\nimport { AxiosError } from 'axios';\nimport {\n CommonCharacter,\n JikanImages,\n JikanResponse,\n JikanUniqueResponse,\n Manga,\n MangaStatistics,\n Recommendation,\n} from '../models';\nimport { MangaSearchParams } from '../models/Params';\n\n/**\n * **Manga Client**\n *\n * Client used to access the Manga Endpoints:\n * - [MangaSearch](https://docs.api.jikan.moe/#tag/manga)\n * - [MangaFullById](https://docs.api.jikan.moe/#tag/manga/operation/getMangaFullById)\n * - [MangaById](https://docs.api.jikan.moe/#tag/manga/operation/getMangaById)\n * - [MangaCharacters](https://docs.api.jikan.moe/#tag/manga/operation/getMangaCharacters)\n * - [MangaPictures](https://docs.api.jikan.moe/#tag/manga/operation/getMangaPictures)\n * - [MangaStatistics](https://docs.api.jikan.moe/#tag/manga/operation/getMangaStatistics)\n * - [MangaRecommendations](https://docs.api.jikan.moe/#tag/manga/operation/getMangaRecommendations)\n *\n * See also: [JikanAPI Documentation](https://docs.api.jikan.moe/)\n */\nexport class MangaClient extends BaseClient {\n /**\n * @argument clientOptions Options for the client.\n */\n constructor(clientOptions?: ClientArgs) {\n super(clientOptions);\n }\n\n /**\n * Get all the filtered Mangas. Returns all the Mangas if no filters are given.\n * @param searchParams Filter parameters\n * @returns A JikanResponse with Manga data\n */\n public async getMangaSearch(searchParams: MangaSearchParams): Promise<JikanResponse<Manga>> {\n return new Promise<JikanResponse<Manga>>((resolve, reject) => {\n const endpoint = `${MangaEndpoints.MangaSearch}`;\n this.api\n .get<JikanResponse<Manga>>(endpoint, { params: searchParams })\n .then((response: CacheAxiosResponse<JikanResponse<Manga>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get a Manga with full information by its ID\n * @param mal_id The Manga ID\n * @returns A JikanUniqueResponse with Manga data\n */\n public async getMangaFullById(mal_id: number): Promise<JikanUniqueResponse<Manga>> {\n return new Promise<JikanUniqueResponse<Manga>>((resolve, reject) => {\n const endpoint = `${MangaEndpoints.MangaFullById.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanUniqueResponse<Manga>>(endpoint)\n .then((response: CacheAxiosResponse<JikanUniqueResponse<Manga>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get a Manga by its ID\n * @param mal_id The Manga ID\n * @returns A JikanUniqueResponse with Manga data\n */\n public async getMangaById(mal_id: number): Promise<JikanUniqueResponse<Manga>> {\n return new Promise<JikanUniqueResponse<Manga>>((resolve, reject) => {\n const endpoint = `${MangaEndpoints.MangaById.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanUniqueResponse<Manga>>(endpoint)\n .then((response: CacheAxiosResponse<JikanUniqueResponse<Manga>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Characters of a specific Manga\n * @param mal_id The Manga ID\n * @returns A JikanResponse with CommonCharacter data\n */\n public async getMangaCharacters(mal_id: number): Promise<JikanResponse<CommonCharacter>> {\n return new Promise<JikanResponse<CommonCharacter>>((resolve, reject) => {\n const endpoint = `${MangaEndpoints.MangaCharacters.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanResponse<CommonCharacter>>(endpoint)\n .then((response: CacheAxiosResponse<JikanResponse<CommonCharacter>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Pictures related to a specific Manga\n * @param mal_id The Manga ID\n * @returns A JikanResponse with JikanImages data\n */\n public async getMangaPictures(mal_id: number): Promise<JikanResponse<JikanImages>> {\n return new Promise<JikanResponse<JikanImages>>((resolve, reject) => {\n const endpoint = `${MangaEndpoints.MangaPictures.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanResponse<JikanImages>>(endpoint)\n .then((response: CacheAxiosResponse<JikanResponse<JikanImages>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Statistics related to a specific Manga\n * @param mal_id The Manga ID\n * @returns A JikanUniqueResponse with MangaStatistics data\n */\n public async getAnimeStatistics(mal_id: number): Promise<JikanUniqueResponse<MangaStatistics>> {\n return new Promise<JikanUniqueResponse<MangaStatistics>>((resolve, reject) => {\n const endpoint = `${MangaEndpoints.MangaStatistics.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanUniqueResponse<MangaStatistics>>(endpoint)\n .then((response: CacheAxiosResponse<JikanUniqueResponse<MangaStatistics>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get Recommendations related to a specific Manga\n * @param mal_id The Manga ID\n * @returns A JikanResponse with Recommendation data\n */\n public async getMangaRecommendation(mal_id: number): Promise<JikanResponse<Recommendation>> {\n return new Promise<JikanResponse<Recommendation>>((resolve, reject) => {\n const endpoint = `${MangaEndpoints.MangaRecommendations.replace('{id}', String(mal_id))}`;\n this.api\n .get<JikanResponse<Recommendation>>(endpoint)\n .then((response: CacheAxiosResponse<JikanResponse<Recommendation>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n}\n","import { BaseClient, ClientArgs } from './base.client';\nimport { AnimeClient } from './anime.client';\nimport { MangaClient } from './manga.client';\nimport { TopClient } from './top.client';\n\n/**\n * **Jikan Client**\n *\n * The main client used to access all the JikanAPI Endpoints:\n * - [Anime](https://docs.api.jikan.moe/#tag/anime)\n * - [Manga](https://docs.api.jikan.moe/#tag/manga)\n * - [Top](https://docs.api.jikan.moe/#tag/top)\n *\n * See also: [JikanAPI Documentation](https://docs.api.jikan.moe/)\n */\nexport class JikanClient extends BaseClient {\n public anime: AnimeClient;\n public manga: MangaClient;\n public top: TopClient;\n\n constructor(clientOptions?: ClientArgs) {\n super(clientOptions);\n\n this.anime = new AnimeClient(clientOptions);\n this.manga = new MangaClient(clientOptions);\n this.top = new TopClient(clientOptions);\n }\n}\n","import { BaseClient, ClientArgs } from './base.client';\nimport { Anime, JikanResponse, Manga } from '../models';\nimport { TopEndpoints } from '../constants';\nimport { CacheAxiosResponse } from 'axios-cache-interceptor';\nimport { AxiosError } from 'axios';\nimport { AnimeTopParams, MangaTopParams } from '../models/Params';\n\n/**\n * **Anime Client**\n *\n * Client used to access the Top Endpoints:\n * - [TopAnime](https://docs.api.jikan.moe/#tag/top/operation/getTopAnime)\n * - [TopManga](https://docs.api.jikan.moe/#tag/top/operation/getTopManga)\n *\n * See also: [JikanAPI Documentation](https://docs.api.jikan.moe/)\n */\nexport class TopClient extends BaseClient {\n /**\n * @argument clientOptions Options for the client.\n */\n constructor(clientOptions?: ClientArgs) {\n super(clientOptions);\n }\n\n /**\n * Get the top Animes\n * @returns A JikanResponse with Anime data\n */\n public async getTopAnime(searchParams: AnimeTopParams): Promise<JikanResponse<Anime>> {\n return new Promise<JikanResponse<Anime>>((resolve, reject) => {\n const endpoint = `${TopEndpoints.TopAnime}`;\n this.api\n .get<JikanResponse<Anime>>(endpoint, { params: searchParams })\n .then((response: CacheAxiosResponse<JikanResponse<Anime>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n\n /**\n * Get the top Mangas\n * @returns A JikanResponse with Manga data\n */\n public async getTopManga(searchParams: MangaTopParams): Promise<JikanResponse<Manga>> {\n return new Promise<JikanResponse<Manga>>((resolve, reject) => {\n const endpoint = `${TopEndpoints.TopManga}`;\n this.api\n .get<JikanResponse<Manga>>(endpoint, { params: searchParams })\n .then((response: CacheAxiosResponse<JikanResponse<Manga>>) => resolve(response.data))\n .catch((error: AxiosError<string>) => reject(error));\n });\n }\n}\n","export * from './Anime';\r\nexport * from './Common';\r\nexport * from './Manga';\r\nexport * from './Response';\r\n","export * from './anime.model';\r\nexport * from './anime-character.model';\r\nexport * from './anime-staff.model';\r\nexport * from './anime-episode.model';\r\nexport * from './anime-video.model';\r\nexport * from './anime-picture.model';\r\nexport * from './anime-statistics.model';\r\n","import {\n JikanImages,\n JikanNamedResource,\n JikanResourcePeriod,\n JikanResourceRelation,\n JikanResourceTitle,\n JikanUniqueResource,\n} from '../Common';\nimport { AnimeYoutubeVideo } from './anime-video.model';\n\nexport interface Anime {\n mal_id: string;\n url: string;\n images: JikanImages;\n trailer: AnimeYoutubeVideo;\n approved: boolean;\n titles: JikanResourceTitle[];\n title: string;\n title_english: string;\n title_japanese: string;\n title_synonyms: string[];\n type: AnimeType;\n source: string;\n episodes: number;\n status: AnimeStatus;\n airing: boolean;\n aired: JikanResourcePeriod;\n duration: string;\n rating: AnimeRating;\n score: number;\n scored_by: number;\n rank: number;\n popularity: number;\n members: number;\n favorites: number;\n synopsis: string;\n background: string;\n season?: AnimeSeason;\n year: number;\n broadcast: AnimeBroadcast;\n producers: JikanUniqueResource[];\n licensors: JikanUniqueResource[];\n studio: JikanUniqueResource[];\n genres: JikanUniqueResource[];\n explicit_genres: JikanUniqueResource[];\n themes: JikanUniqueResource[];\n demographic: JikanUniqueResource[];\n relations?: JikanResourceRelation[];\n theme?: AnimeTheme;\n external?: JikanNamedResource[];\n streaming: JikanNamedResource[];\n}\n\nexport interface AnimeBroadcast {\n day: string;\n time: string;\n timezone: string;\n string: string;\n}\n\nexport interface AnimeTheme {\n openings: string[];\n endings: string[];\n}\n\nexport enum AnimeType {\n tv = 'TV',\n movie = 'Movie',\n ova = 'Ova',\n special = 'Special',\n ona = 'Ona',\n music = 'Music',\n}\n\nexport enum AnimeStatus {\n finished = 'Finished Airing',\n airing = 'Currently Airing',\n complete = 'Complete',\n}\n\nexport enum AnimeRating {\n g = 'g',\n pg = 'pg',\n pg13 = 'pg13',\n r17 = 'r17',\n r = 'r',\n rx = 'rx',\n}\n\nexport enum AnimeSeason {\n spring = 'spring',\n summer = 'summer',\n fall = 'fall',\n winter = 'winter',\n}\n","import { CommonCharacter } from '../Common/character.model';\r\nimport { JikanPerson } from '../Common/person.model';\r\n\r\nexport interface AnimeCharacter extends CommonCharacter {\r\n voice_actors: AnimeCharacterVoiceActor[];\r\n}\r\n\r\nexport interface AnimeCharacterVoiceActor {\r\n person: JikanPerson;\r\n language: string;\r\n}\r\n","import { JikanPerson } from '../Common';\r\n\r\nexport interface AnimeStaff {\r\n person: JikanPerson;\r\n positions: string[];\r\n}\r\n","export interface AnimeEpisode {\r\n mal_id: number;\r\n url: string;\r\n title: string;\r\n title_japanese: string;\r\n title_romanji: string;\r\n duration: number;\r\n aired: string;\r\n filler: boolean;\r\n recap: boolean;\r\n forum_url: string;\r\n}\r\n","import { JikanImages, JikanImagesCollection } from '../Common';\r\n\r\nexport interface AnimeVideo {\r\n promo: AnimeVideoPromo[];\r\n episodes: AnimeVideoEpisode[];\r\n music_videos: AnimeMusicVideo[];\r\n}\r\n\r\nexport interface AnimeVideoPromo {\r\n title: string;\r\n trailer: AnimeYoutubeVideo;\r\n}\r\n\r\nexport interface AnimeYoutubeVideo {\r\n youtube_id: string;\r\n url: string;\r\n embed_url: string;\r\n images?: JikanImagesCollection;\r\n}\r\n\r\nexport interface AnimeVideoEpisode {\r\n mal_id: number;\r\n url: string;\r\n title: string;\r\n episode: string;\r\n images: JikanImages;\r\n}\r\n\r\nexport interface AnimeMusicVideo {\r\n title: string;\r\n video: AnimeYoutubeVideo;\r\n meta: AnimeVideoMeta;\r\n}\r\n\r\nexport interface AnimeVideoMeta {\r\n title: string;\r\n author: string;\r\n}\r\n","import { JikanImages } from '../Common';\r\n\r\nexport interface AnimePicture {\r\n images: JikanImages;\r\n}\r\n","import { Statistics } from '../Common';\n\nexport interface AnimeStatistics extends Statistics {\n watching: number;\n plan_to_watch: number;\n}\n","export * from './resource.model';\r\nexport * from './image.model';\r\nexport * from './character.model';\r\nexport * from './person.model';\r\nexport * from './recommendation.model';\r\nexport * from './statistics.model';\r\n","export interface JikanUniqueResource {\n mal_id: number;\n type: string;\n name: string;\n url: string;\n}\n\nexport interface JikanNamedResource {\n name: string;\n url: string;\n}\n\nexport interface JikanResourceTitle {\n type: string;\n title: string;\n}\n\nexport interface JikanResourcePeriod {\n from: string;\n to: string;\n prop: {\n form: { day: number; month: number; year: number };\n to: { day: number; month: number; year: number };\n string: string;\n };\n}\n\nexport interface JikanResourceRelation {\n relation: string;\n entry: JikanUniqueResource[];\n}\n","export interface JikanImages {\r\n jpg: JikanImagesCollection;\r\n webp?: JikanImagesCollection;\r\n}\r\n\r\nexport interface JikanImagesCollection {\r\n image_url: string;\r\n small_image_url?: string;\r\n medium_image_url?: string;\r\n large_image_url?: string;\r\n maximum_image_url?: string;\r\n}\r\n","import { JikanImages } from './image.model';\n\nexport interface CommonCharacter {\n character: CommonCharacterData;\n role: CharacterRole;\n}\n\nexport interface CommonCharacterData {\n mal_id: number;\n url: string;\n images: JikanImages;\n name: string;\n}\n\nexport enum CharacterRole {\n main = 'Main',\n supporting = 'Supporting',\n}\n","import { JikanImages } from './image.model';\r\n\r\nexport interface JikanPerson {\r\n mal_id: number;\r\n url: string;\r\n images: JikanImages;\r\n name: string;\r\n}\r\n","import { JikanImages } from './image.model';\r\n\r\nexport interface Recommendation {\r\n entry: RecommendationEntry;\r\n}\r\n\r\nexport interface RecommendationEntry {\r\n mal_id: number;\r\n url: string;\r\n images: JikanImages;\r\n title: string;\r\n}\r\n","export interface Statistics {\r\n completed: number;\r\n on_hold: number;\r\n dropped: number;\r\n total: number;\r\n scores: StatisticsScore[];\r\n}\r\n\r\nexport interface StatisticsScore {\r\n score: number;\r\n votes: number;\r\n percentage: number;\r\n}\r\n","export * from './manga.model';\nexport * from './manga-statistics.model';\n","import {\n JikanImages,\n JikanNamedResource,\n JikanResourcePeriod,\n JikanResourceRelation,\n JikanResourceTitle,\n JikanUniqueResource,\n} from '../Common';\n\nexport interface Manga {\n mal_id: number;\n url: string;\n images: JikanImages;\n approved: boolean;\n titles: JikanResourceTitle[];\n title: string;\n title_japanese: string;\n title_synonyms?: string[];\n type: MangaType;\n chapters: number;\n volumes: number;\n status: MangaStatus;\n publishing: boolean;\n published: JikanResourcePeriod;\n score: number;\n scored_by: number;\n rank: number;\n popularity: number;\n members: number;\n favorites: number;\n synopsis: string;\n background: string;\n authors: JikanUniqueResource[];\n serializations: JikanUniqueResource[];\n explicit_genres: JikanUniqueResource[];\n themes: JikanUniqueResource[];\n demographics: JikanUniqueResource[];\n relations?: JikanResourceRelation[];\n external?: JikanNamedResource[];\n}\n\nexport enum MangaType {\n manga = 'Manga',\n novel = 'Novel',\n lightnovel = 'Lightnovel',\n oneshot = 'Oneshot',\n doujin = 'Doujin',\n manwha = 'Manwha',\n manhua = 'Manhua',\n}\n\nexport enum MangaStatus {\n publishing = 'Publishing',\n complete = 'Complete',\n hiatus = 'Hiatus',\n discontinued = 'Discontinued',\n upcoming = 'Upcoming',\n}\n","import { Statistics } from '../Common';\n\nexport interface MangaStatistics extends Statistics {\n reading: number;\n plan_to_read: number;\n}\n","export * from './response.model';\r\n","export interface JikanPagination {\r\n last_visible_page: number;\r\n has_next_page: boolean;\r\n items?: JikanPaginationItems;\r\n}\r\n\r\nexport interface JikanPaginationItems {\r\n count: number;\r\n total: number;\r\n per_page: number;\r\n}\r\n\r\nexport interface JikanResponse<T> {\r\n data: T[];\r\n pagination?: JikanPagination;\r\n}\r\n\r\nexport interface JikanUniqueResponse<T> {\r\n data: T;\r\n pagination?: JikanPagination;\r\n}\r\n"],"names":[],"version":3,"file":"index.js.map"}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/** @type {import('@jest/types').Config.InitialOptions} */
|
|
4
|
+
const jestConfig = {
|
|
5
|
+
displayName: 'jikan-ts',
|
|
6
|
+
clearMocks: true,
|
|
7
|
+
testEnvironment: 'node',
|
|
8
|
+
transform: {
|
|
9
|
+
'^.+\\.(t|j)sx?$': '@swc/jest',
|
|
10
|
+
},
|
|
11
|
+
collectCoverageFrom: [
|
|
12
|
+
'src/**/*.ts',
|
|
13
|
+
'!**/*.d.ts',
|
|
14
|
+
'!**/node_modules/**',
|
|
15
|
+
'!**/dist/**',
|
|
16
|
+
'!**/src/models/**',
|
|
17
|
+
'!**/src/constants/**',
|
|
18
|
+
'!**/src/config/**',
|
|
19
|
+
'!**/src/structures/**',
|
|
20
|
+
],
|
|
21
|
+
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'],
|
|
22
|
+
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
module.exports = jestConfig;
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tutkli/jikan-ts",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Node.js wrapper for the Jikan API with build-in typings.",
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prebuild": "rimraf dist",
|
|
10
|
+
"watch": "parcel watch",
|
|
11
|
+
"build": "parcel build",
|
|
12
|
+
"test:coverage": "jest --coverage",
|
|
13
|
+
"test:dev": "jest --verbose --colors --expand --maxWorkers=50% --detectOpenHandles --errorOnDeprecated --bail"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/tutkli/jikan-ts.git"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"jikan",
|
|
21
|
+
"jikan-api",
|
|
22
|
+
"jikanAPI",
|
|
23
|
+
"MyAnimeList"
|
|
24
|
+
],
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "Clara Castillo",
|
|
27
|
+
"url": "https://github.com/tutkli"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/tutkli/jikan-ts/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/tutkli/jikan-ts#readme",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"axios": "^0.27.2",
|
|
36
|
+
"axios-cache-interceptor": "^0.10.7",
|
|
37
|
+
"pino": "^8.7.0",
|
|
38
|
+
"pino-pretty": "^9.1.1",
|
|
39
|
+
"tslib": "^2.4.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@parcel/packager-ts": "^2.8.0",
|
|
43
|
+
"@parcel/transformer-typescript-types": "^2.8.0",
|
|
44
|
+
"@swc/core": "^1.3.14",
|
|
45
|
+
"@swc/jest": "^0.2.23",
|
|
46
|
+
"@types/jest": "^29.2.2",
|
|
47
|
+
"@types/node": "^18.11.9",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
49
|
+
"eslint": "^8.27.0",
|
|
50
|
+
"eslint-config-prettier": "^8.5.0",
|
|
51
|
+
"eslint-plugin-jest": "^27.1.4",
|
|
52
|
+
"eslint-plugin-node": "^11.1.0",
|
|
53
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
54
|
+
"jest": "^29.3.1",
|
|
55
|
+
"parcel": "^2.8.0",
|
|
56
|
+
"prettier": "^2.7.1",
|
|
57
|
+
"rimraf": "^3.0.2",
|
|
58
|
+
"typescript": "~4.7"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AnimeClient } from '../clients';
|
|
2
|
+
import { Anime, JikanResponse, JikanUniqueResponse } from '../models';
|
|
3
|
+
import { AnimeSearchParams } from '../models/Params';
|
|
4
|
+
|
|
5
|
+
describe('test Anime Client', () => {
|
|
6
|
+
let client: AnimeClient;
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
client = new AnimeClient();
|
|
9
|
+
});
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should get animes filtered by params', async () => {
|
|
15
|
+
const params: AnimeSearchParams = { limit: 3, score: 9 };
|
|
16
|
+
const data = await client.getAnimeSearch(params).then((response: JikanResponse<Anime>) => response.data);
|
|
17
|
+
|
|
18
|
+
expect(data).toHaveLength(3);
|
|
19
|
+
for (const anime of data) {
|
|
20
|
+
expect(anime.score).toBeGreaterThanOrEqual(9);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should get a full anime by its ID', async () => {
|
|
25
|
+
const data = await client.getAnimeFullById(1).then((response: JikanUniqueResponse<Anime>) => response.data);
|
|
26
|
+
expect(data.mal_id).toBe(1);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should get an anime by its ID', async () => {
|
|
30
|
+
const data = await client.getAnimeById(1).then((response: JikanUniqueResponse<Anime>) => response.data);
|
|
31
|
+
expect(data.mal_id).toBe(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MangaClient } from '../clients';
|
|
2
|
+
import { MangaSearchParams } from '../models/Params';
|
|
3
|
+
import { JikanResponse, JikanUniqueResponse, Manga } from '../models';
|
|
4
|
+
|
|
5
|
+
describe('test Manga Client', () => {
|
|
6
|
+
let client: MangaClient;
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
client = new MangaClient();
|
|
9
|
+
});
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should get mangas filtered by params', async () => {
|
|
15
|
+
const params: MangaSearchParams = { limit: 3, score: 9 };
|
|
16
|
+
const data = await client.getMangaSearch(params).then((response: JikanResponse<Manga>) => response.data);
|
|
17
|
+
|
|
18
|
+
expect(data).toHaveLength(3);
|
|
19
|
+
for (const anime of data) {
|
|
20
|
+
expect(anime.score).toBeGreaterThanOrEqual(9);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should get a full manga by its ID', async () => {
|
|
25
|
+
const data = await client.getMangaFullById(1).then((response: JikanUniqueResponse<Manga>) => response.data);
|
|
26
|
+
expect(data.mal_id).toBe(1);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should get an manga by its ID', async () => {
|
|
30
|
+
const data = await client.getMangaById(1).then((response: JikanUniqueResponse<Manga>) => response.data);
|
|
31
|
+
expect(data.mal_id).toBe(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AnimeTopParams, MangaTopParams, TopAnimeFilter, TopMangaFilter } from '../models/Params';
|
|
2
|
+
import { Anime, AnimeStatus, JikanResponse, Manga, MangaStatus } from '../models';
|
|
3
|
+
import { TopClient } from '../clients/top.client';
|
|
4
|
+
|
|
5
|
+
describe('test Top Client', () => {
|
|
6
|
+
let client: TopClient;
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
client = new TopClient();
|
|
9
|
+
});
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should get top animes filtered by params', async () => {
|
|
15
|
+
const params: AnimeTopParams = { limit: 3, filter: TopAnimeFilter.airing };
|
|
16
|
+
const data = await client.getTopAnime(params).then((response: JikanResponse<Anime>) => response.data);
|
|
17
|
+
|
|
18
|
+
expect(data).toHaveLength(3);
|
|
19
|
+
for (const anime of data) {
|
|
20
|
+
expect(anime.status).toBe(AnimeStatus.airing);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should get top mangas filtered by params', async () => {
|
|
25
|
+
const params: MangaTopParams = { limit: 3, filter: TopMangaFilter.publishing };
|
|
26
|
+
const data = await client.getTopManga(params).then((response: JikanResponse<Manga>) => response.data);
|
|
27
|
+
|
|
28
|
+
expect(data).toHaveLength(3);
|
|
29
|
+
for (const manga of data) {
|
|
30
|
+
expect(manga.status).toBe(MangaStatus.publishing);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { BaseClient, ClientArgs } from './base.client';
|
|
2
|
+
import { AnimeEndpoints } from '../constants';
|
|
3
|
+
import { CacheAxiosResponse } from 'axios-cache-interceptor';
|
|
4
|
+
import { AxiosError } from 'axios';
|
|
5
|
+
import {
|
|
6
|
+
Anime,
|
|
7
|
+
AnimeCharacter,
|
|
8
|
+
AnimeEpisode,
|
|
9
|
+
AnimePicture,
|
|
10
|
+
AnimeStaff,
|
|
11
|
+
AnimeStatistics,
|
|
12
|
+
AnimeVideo,
|
|
13
|
+
AnimeVideoEpisode,
|
|
14
|
+
JikanResponse,
|
|
15
|
+
JikanUniqueResponse,
|
|
16
|
+
Recommendation,
|
|
17
|
+
} from '../models';
|
|
18
|
+
import { AnimeSearchParams } from '../models/Params';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* **Anime Client**
|
|
22
|
+
*
|
|
23
|
+
* Client used to access the Anime Endpoints:
|
|
24
|
+
* - [AnimeSearch](https://docs.api.jikan.moe/#tag/anime)
|
|
25
|
+
* - [AnimeFullById](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeFullById)
|
|
26
|
+
* - [AnimeById](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeById)
|
|
27
|
+
* - [AnimeCharacters](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeCharacters)
|
|
28
|
+
* - [AnimeStaff](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeStaff)
|
|
29
|
+
* - [AnimeEpisodes](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeEpisodes)
|
|
30
|
+
* - [AnimeEpisodeById](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeEpisodeById)
|
|
31
|
+
* - [AnimeVideos](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeVideos)
|
|
32
|
+
* - [AnimeVideosEpisodes](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeVideosEpisodes)
|
|
33
|
+
* - [AnimePictures](https://docs.api.jikan.moe/#tag/anime/operation/getAnimePictures)
|
|
34
|
+
* - [AnimeStatistics](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeStatistics)
|
|
35
|
+
* - [AnimeRecommendations](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeRecommendations)
|
|
36
|
+
*
|
|
37
|
+
* See also: [JikanAPI](https://docs.api.jikan.moe/)
|
|
38
|
+
*/
|
|
39
|
+
export class AnimeClient extends BaseClient {
|
|
40
|
+
/**
|
|
41
|
+
* @argument clientOptions Options for the client.
|
|
42
|
+
*/
|
|
43
|
+
constructor(clientOptions?: ClientArgs) {
|
|
44
|
+
super(clientOptions);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get all the filtered Animes. Returns all the Animes if no filters are given.
|
|
49
|
+
* @param searchParams Filter parameters
|
|
50
|
+
* @returns A JikanResponse with Anime data
|
|
51
|
+
*/
|
|
52
|
+
public async getAnimeSearch(searchParams?: AnimeSearchParams): Promise<JikanResponse<Anime>> {
|
|
53
|
+
return new Promise<JikanResponse<Anime>>((resolve, reject) => {
|
|
54
|
+
const endpoint = `${AnimeEndpoints.AnimeSearch}`;
|
|
55
|
+
this.api
|
|
56
|
+
.get<JikanResponse<Anime>>(endpoint, { params: searchParams })
|
|
57
|
+
.then((response: CacheAxiosResponse<JikanResponse<Anime>>) => resolve(response.data))
|
|
58
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get a complete Anime resource data
|
|
64
|
+
* @param mal_id The Anime ID
|
|
65
|
+
* @returns A JikanUniqueResponse with Anime data
|
|
66
|
+
*/
|
|
67
|
+
public async getAnimeFullById(mal_id: number): Promise<JikanUniqueResponse<Anime>> {
|
|
68
|
+
return new Promise<JikanUniqueResponse<Anime>>((resolve, reject) => {
|
|
69
|
+
const endpoint = `${AnimeEndpoints.AnimeFullById.replace('{id}', String(mal_id))}`;
|
|
70
|
+
this.api
|
|
71
|
+
.get<JikanUniqueResponse<Anime>>(endpoint)
|
|
72
|
+
.then((response: CacheAxiosResponse<JikanUniqueResponse<Anime>>) => resolve(response.data))
|
|
73
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get Anime resource data
|
|
79
|
+
* @param mal_id The Anime ID
|
|
80
|
+
* @returns A JikanUniqueResponse with Anime data
|
|
81
|
+
*/
|
|
82
|
+
public async getAnimeById(mal_id: number): Promise<JikanUniqueResponse<Anime>> {
|
|
83
|
+
return new Promise<JikanUniqueResponse<Anime>>((resolve, reject) => {
|
|
84
|
+
const endpoint = `${AnimeEndpoints.AnimeById.replace('{id}', String(mal_id))}`;
|
|
85
|
+
this.api
|
|
86
|
+
.get<JikanUniqueResponse<Anime>>(endpoint)
|
|
87
|
+
.then((response: CacheAxiosResponse<JikanUniqueResponse<Anime>>) => resolve(response.data))
|
|
88
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get Characters of a specific Anime
|
|
94
|
+
* @param mal_id The Anime ID
|
|
95
|
+
* @returns A JikanResponse with AnimeCharacter data
|
|
96
|
+
*/
|
|
97
|
+
public async getAnimeCharacters(mal_id: number): Promise<JikanResponse<AnimeCharacter>> {
|
|
98
|
+
return new Promise<JikanResponse<AnimeCharacter>>((resolve, reject) => {
|
|
99
|
+
const endpoint = `${AnimeEndpoints.AnimeCharacters.replace('{id}', String(mal_id))}`;
|
|
100
|
+
this.api
|
|
101
|
+
.get<JikanResponse<AnimeCharacter>>(endpoint)
|
|
102
|
+
.then((response: CacheAxiosResponse<JikanResponse<AnimeCharacter>>) => resolve(response.data))
|
|
103
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get Staff of a specific Anime
|
|
109
|
+
* @param mal_id The Anime ID
|
|
110
|
+
* @returns A JikanResponse with AnimeStaff data
|
|
111
|
+
*/
|
|
112
|
+
public async getAnimeStaff(mal_id: number): Promise<JikanResponse<AnimeStaff>> {
|
|
113
|
+
return new Promise<JikanResponse<AnimeStaff>>((resolve, reject) => {
|
|
114
|
+
const endpoint = `${AnimeEndpoints.AnimeStaff.replace('{id}', String(mal_id))}`;
|
|
115
|
+
this.api
|
|
116
|
+
.get<JikanResponse<AnimeStaff>>(endpoint)
|
|
117
|
+
.then((response: CacheAxiosResponse<JikanResponse<AnimeStaff>>) => resolve(response.data))
|
|
118
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get a list of all the episodes of a specific Anime
|
|
124
|
+
* @param mal_id The Anime ID
|
|
125
|
+
* @returns A JikanResponse with AnimeEpisode data
|
|
126
|
+
*/
|
|
127
|
+
public async getAnimeEpisodes(mal_id: number): Promise<JikanResponse<AnimeEpisode>> {
|
|
128
|
+
return new Promise<JikanResponse<AnimeEpisode>>((resolve, reject) => {
|
|
129
|
+
const endpoint = `${AnimeEndpoints.AnimeEpisodes.replace('{id}', String(mal_id))}`;
|
|
130
|
+
this.api
|
|
131
|
+
.get<JikanResponse<AnimeEpisode>>(endpoint)
|
|
132
|
+
.then((response: CacheAxiosResponse<JikanResponse<AnimeEpisode>>) => resolve(response.data))
|
|
133
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get a single Episode of a specific Anime by its ID
|
|
139
|
+
* @param anime_mal_id The Anime ID
|
|
140
|
+
* @param episode_mal_id The Episode ID
|
|
141
|
+
* @returns A JikanUniqueResponse with AnimeEpisode data
|
|
142
|
+
*/
|
|
143
|
+
public async getAnimeEpisodeById(
|
|
144
|
+
anime_mal_id: number,
|
|
145
|
+
episode_mal_id: number
|
|
146
|
+
): Promise<JikanUniqueResponse<AnimeEpisode>> {
|
|
147
|
+
return new Promise<JikanUniqueResponse<AnimeEpisode>>((resolve, reject) => {
|
|
148
|
+
const endpoint = `${AnimeEndpoints.AnimeEpisodeById.replace('{id}', String(anime_mal_id)).replace(
|
|
149
|
+
'{episode}',
|
|
150
|
+
String(episode_mal_id)
|
|
151
|
+
)}`;
|
|
152
|
+
this.api
|
|
153
|
+
.get<JikanUniqueResponse<AnimeEpisode>>(endpoint)
|
|
154
|
+
.then((response: CacheAxiosResponse<JikanUniqueResponse<AnimeEpisode>>) => resolve(response.data))
|
|
155
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Get Videos related to a specific Anime
|
|
161
|
+
* @param mal_id The Anime ID
|
|
162
|
+
* @returns A JikanUniqueResponse with AnimeVideo data
|
|
163
|
+
*/
|
|
164
|
+
public async getAnimeVideos(mal_id: number): Promise<JikanUniqueResponse<AnimeVideo>> {
|
|
165
|
+
return new Promise<JikanUniqueResponse<AnimeVideo>>((resolve, reject) => {
|
|
166
|
+
const endpoint = `${AnimeEndpoints.AnimeVideos.replace('{id}', String(mal_id))}`;
|
|
167
|
+
this.api
|
|
168
|
+
.get<JikanUniqueResponse<AnimeVideo>>(endpoint)
|
|
169
|
+
.then((response: CacheAxiosResponse<JikanUniqueResponse<AnimeVideo>>) => resolve(response.data))
|
|
170
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Get Episode Videos related to a specific Anime
|
|
176
|
+
* @param mal_id The Anime ID
|
|
177
|
+
* @returns A JikanResponse with AnimeVideoEpisode data
|
|
178
|
+
*/
|
|
179
|
+
public async getAnimeVideosEpisode(mal_id: number): Promise<JikanResponse<AnimeVideoEpisode>> {
|
|
180
|
+
return new Promise<JikanResponse<AnimeVideoEpisode>>((resolve, reject) => {
|
|
181
|
+
const endpoint = `${AnimeEndpoints.AnimeVideosEpisodes.replace('{id}', String(mal_id))}`;
|
|
182
|
+
this.api
|
|
183
|
+
.get<JikanResponse<AnimeVideoEpisode>>(endpoint)
|
|
184
|
+
.then((response: CacheAxiosResponse<JikanResponse<AnimeVideoEpisode>>) => resolve(response.data))
|
|
185
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Get Pictures related to a specific Anime
|
|
191
|
+
* @param mal_id The Anime ID
|
|
192
|
+
* @returns A JikanResponse with AnimePicture data
|
|
193
|
+
*/
|
|
194
|
+
public async getAnimePictures(mal_id: number): Promise<JikanResponse<AnimePicture>> {
|
|
195
|
+
return new Promise<JikanResponse<AnimePicture>>((resolve, reject) => {
|
|
196
|
+
const endpoint = `${AnimeEndpoints.AnimePictures.replace('{id}', String(mal_id))}`;
|
|
197
|
+
this.api
|
|
198
|
+
.get<JikanResponse<AnimePicture>>(endpoint)
|
|
199
|
+
.then((response: CacheAxiosResponse<JikanResponse<AnimePicture>>) => resolve(response.data))
|
|
200
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get Statistics related to a specific Anime
|
|
206
|
+
* @param mal_id The Anime ID
|
|
207
|
+
* @returns A JikanUniqueResponse with AnimeStatistics data
|
|
208
|
+
*/
|
|
209
|
+
public async getAnimeStatistics(mal_id: number): Promise<JikanUniqueResponse<AnimeStatistics>> {
|
|
210
|
+
return new Promise<JikanUniqueResponse<AnimeStatistics>>((resolve, reject) => {
|
|
211
|
+
const endpoint = `${AnimeEndpoints.AnimeStatistics.replace('{id}', String(mal_id))}`;
|
|
212
|
+
this.api
|
|
213
|
+
.get<JikanUniqueResponse<AnimeStatistics>>(endpoint)
|
|
214
|
+
.then((response: CacheAxiosResponse<JikanUniqueResponse<AnimeStatistics>>) => resolve(response.data))
|
|
215
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Get Recommendations related to a specific Anime
|
|
221
|
+
* @param mal_id The Anime ID
|
|
222
|
+
* @returns A JikanResponse with Recommendation data
|
|
223
|
+
*/
|
|
224
|
+
public async getAnimeRecommendation(mal_id: number): Promise<JikanResponse<Recommendation>> {
|
|
225
|
+
return new Promise<JikanResponse<Recommendation>>((resolve, reject) => {
|
|
226
|
+
const endpoint = `${AnimeEndpoints.AnimeRecommendations.replace('{id}', String(mal_id))}`;
|
|
227
|
+
this.api
|
|
228
|
+
.get<JikanResponse<Recommendation>>(endpoint)
|
|
229
|
+
.then((response: CacheAxiosResponse<JikanResponse<Recommendation>>) => resolve(response.data))
|
|
230
|
+
.catch((error: AxiosError<string>) => reject(error));
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Logger, LoggerOptions } from 'pino';
|
|
2
|
+
import {
|
|
3
|
+
AxiosCacheInstance,
|
|
4
|
+
CacheAxiosResponse,
|
|
5
|
+
CacheOptions,
|
|
6
|
+
CacheRequestConfig,
|
|
7
|
+
setupCache,
|
|
8
|
+
} from 'axios-cache-interceptor';
|
|
9
|
+
import axios, { AxiosError } from 'axios';
|
|
10
|
+
import { BaseURL } from '../constants';
|
|
11
|
+
import {
|
|
12
|
+
createLogger,
|
|
13
|
+
DEFAULT_CACHE_OPTIONS,
|
|
14
|
+
handleRequest,
|
|
15
|
+
handleRequestError,
|
|
16
|
+
handleResponse,
|
|
17
|
+
handleResponseError,
|
|
18
|
+
} from '../config';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* **Client Args**
|
|
22
|
+
* Used to pass optional configuration for logging and cache to the clients.
|
|
23
|
+
*/
|
|
24
|
+
export interface ClientArgs {
|
|
25
|
+
/**
|
|
26
|
+
* **Logger Options**
|
|
27
|
+
* Options for the client logger.
|
|
28
|
+
* @see https://getpino.io/#/docs/api?id=options
|
|
29
|
+
*/
|
|
30
|
+
logOptions?: LoggerOptions;
|
|
31
|
+
/**
|
|
32
|
+
* **Axios Cache Options**
|
|
33
|
+
* Options for cache.
|
|
34
|
+
* @see https://axios-cache-interceptor.js.org/#/pages/configuration
|
|
35
|
+
*/
|
|
36
|
+
cacheOptions?: CacheOptions;
|
|
37
|
+
/**
|
|
38
|
+
* **Base URL**
|
|
39
|
+
* Location of the JikanAPI. Leave empty to use the official JikanAPI instance.
|
|
40
|
+
*/
|
|
41
|
+
baseURL?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* **Base Client** This client is responsible for creating an Axios Instance and the cache and logging configurations
|
|
46
|
+
*/
|
|
47
|
+
export abstract class BaseClient {
|
|
48
|
+
public api: AxiosCacheInstance;
|
|
49
|
+
public logger: Logger;
|
|
50
|
+
|
|
51
|
+
constructor(clientOptions?: ClientArgs) {
|
|
52
|
+
this.api = setupCache(
|
|
53
|
+
axios.create({
|
|
54
|
+
baseURL: clientOptions?.baseURL ?? BaseURL.REST,
|
|
55
|
+
headers: {
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
{
|
|
60
|
+
storage: clientOptions?.cacheOptions?.storage ?? DEFAULT_CACHE_OPTIONS.storage,
|
|
61
|
+
generateKey: clientOptions?.cacheOptions?.generateKey ?? DEFAULT_CACHE_OPTIONS.generateKey,
|
|
62
|
+
headerInterpreter: clientOptions?.cacheOptions?.headerInterpreter ?? DEFAULT_CACHE_OPTIONS.headerInterpreter,
|
|
63
|
+
debug: clientOptions?.cacheOptions?.debug ?? DEFAULT_CACHE_OPTIONS.debug,
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
this.logger = createLogger({
|
|
68
|
+
enabled: !(clientOptions?.logOptions?.enabled === undefined || clientOptions?.logOptions.enabled === false),
|
|
69
|
+
...clientOptions?.logOptions,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
this.api.interceptors.request.use(
|
|
73
|
+
(config: CacheRequestConfig) => handleRequest(config, this.logger),
|
|
74
|
+
(error: AxiosError<string>) => handleRequestError(error, this.logger)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
this.api.interceptors.response.use(
|
|
78
|
+
(response: CacheAxiosResponse) => handleResponse(response, this.logger),
|
|
79
|
+
(error: AxiosError<string>) => handleResponseError(error, this.logger)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseClient, ClientArgs } from './base.client';
|
|
2
|
+
import { AnimeClient } from './anime.client';
|
|
3
|
+
import { MangaClient } from './manga.client';
|
|
4
|
+
import { TopClient } from './top.client';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* **Jikan Client**
|
|
8
|
+
*
|
|
9
|
+
* The main client used to access all the JikanAPI Endpoints:
|
|
10
|
+
* - [Anime](https://docs.api.jikan.moe/#tag/anime)
|
|
11
|
+
* - [Manga](https://docs.api.jikan.moe/#tag/manga)
|
|
12
|
+
* - [Top](https://docs.api.jikan.moe/#tag/top)
|
|
13
|
+
*
|
|
14
|
+
* See also: [JikanAPI Documentation](https://docs.api.jikan.moe/)
|
|
15
|
+
*/
|
|
16
|
+
export class JikanClient extends BaseClient {
|
|
17
|
+
public anime: AnimeClient;
|
|
18
|
+
public manga: MangaClient;
|
|
19
|
+
public top: TopClient;
|
|
20
|
+
|
|
21
|
+
constructor(clientOptions?: ClientArgs) {
|
|
22
|
+
super(clientOptions);
|
|
23
|
+
|
|
24
|
+
this.anime = new AnimeClient(clientOptions);
|
|
25
|
+
this.manga = new MangaClient(clientOptions);
|
|
26
|
+
this.top = new TopClient(clientOptions);
|
|
27
|
+
}
|
|
28
|
+
}
|