From 03b3550b49fa0e0038c7d7d8c84f1bb3acc33bb6 Mon Sep 17 00:00:00 2001 From: Ritesh Ghosh Date: Wed, 22 Nov 2023 13:56:16 +0530 Subject: fix(ts): add strict file & type imports --- src/parsers/animeAboutInfo.ts | 13 ++++++------- src/parsers/animeCategory.ts | 17 ++++++++--------- src/parsers/animeEpisodeSrcs.ts | 17 ++++++++--------- src/parsers/animeEpisodes.ts | 8 ++++---- src/parsers/animeGenre.ts | 13 ++++++------- src/parsers/animeProducer.ts | 11 +++++------ src/parsers/animeSearch.ts | 11 +++++------ src/parsers/animeSearchSuggestion.ts | 11 +++++------ src/parsers/episodeServers.ts | 8 ++++---- src/parsers/homePage.ts | 11 +++++------ 10 files changed, 56 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/parsers/animeAboutInfo.ts b/src/parsers/animeAboutInfo.ts index 1a2bf72..3f89ed5 100644 --- a/src/parsers/animeAboutInfo.ts +++ b/src/parsers/animeAboutInfo.ts @@ -1,16 +1,15 @@ -import axios, { AxiosError } from "axios"; -import { load, CheerioAPI, SelectorType } from "cheerio"; import { SRC_BASE_URL, + extractAnimes, ACCEPT_HEADER, USER_AGENT_HEADER, ACCEPT_ENCODING_HEADER, extractMostPopularAnimes, - extractAnimes, -} from "../utils"; - -import createHttpError, { HttpError } from "http-errors"; -import { ScrapedAnimeAboutInfo } from "../models/parsers"; +} from "../utils/index.js"; +import axios, { AxiosError } from "axios"; +import createHttpError, { type HttpError } from "http-errors"; +import { load, type CheerioAPI, type SelectorType } from "cheerio"; +import { type ScrapedAnimeAboutInfo } from "../models/parsers/index.js"; // /anime/info?id=${anime-id} async function scrapeAnimeAboutInfo( diff --git a/src/parsers/animeCategory.ts b/src/parsers/animeCategory.ts index 025316e..809d978 100644 --- a/src/parsers/animeCategory.ts +++ b/src/parsers/animeCategory.ts @@ -1,17 +1,16 @@ -import axios, { AxiosError } from "axios"; -import { load, CheerioAPI, SelectorType } from "cheerio"; import { SRC_BASE_URL, + extractAnimes, ACCEPT_HEADER, USER_AGENT_HEADER, - ACCEPT_ENCODING_HEADER, - extractAnimes, extractTop10Animes, -} from "../utils"; - -import { AnimeCategories } from "../models/anime"; -import createHttpError, { HttpError } from "http-errors"; -import { ScrapedAnimeCategory } from "../models/parsers"; + ACCEPT_ENCODING_HEADER, +} from "../utils/index.js"; +import axios, { AxiosError } from "axios"; +import { type AnimeCategories } from "../models/anime.js"; +import createHttpError, { type HttpError } from "http-errors"; +import { load, type CheerioAPI, type SelectorType } from "cheerio"; +import { type ScrapedAnimeCategory } from "../models/parsers/index.js"; // /anime/:category?page=${page} async function scrapeAnimeCategory( diff --git a/src/parsers/animeEpisodeSrcs.ts b/src/parsers/animeEpisodeSrcs.ts index 7746ec0..14cdd7c 100644 --- a/src/parsers/animeEpisodeSrcs.ts +++ b/src/parsers/animeEpisodeSrcs.ts @@ -1,16 +1,15 @@ import { - SRC_BASE_URL, SRC_AJAX_URL, - USER_AGENT_HEADER, + SRC_BASE_URL, retrieveServerId, -} from "../utils"; - + USER_AGENT_HEADER, +} from "../utils/index.js"; import axios, { AxiosError } from "axios"; -import { load, CheerioAPI } from "cheerio"; -import { AnimeServers, Servers } from "../models/anime"; -import createHttpError, { HttpError } from "http-errors"; -import { ScrapedAnimeEpisodesSources } from "../models/parsers"; -import { RapidCloud, StreamSB, StreamTape } from "../extractors"; +import { load, type CheerioAPI } from "cheerio"; +import createHttpError, { type HttpError } from "http-errors"; +import { type AnimeServers, Servers } from "../models/anime.js"; +import { RapidCloud, StreamSB, StreamTape } from "../extractors/index.js"; +import { type ScrapedAnimeEpisodesSources } from "../models/parsers/index.js"; // vidtreaming -> 4 // rapidcloud -> 1 diff --git a/src/parsers/animeEpisodes.ts b/src/parsers/animeEpisodes.ts index c5bcb7f..8e624b4 100644 --- a/src/parsers/animeEpisodes.ts +++ b/src/parsers/animeEpisodes.ts @@ -4,11 +4,11 @@ import { ACCEPT_HEADER, USER_AGENT_HEADER, ACCEPT_ENCODING_HEADER, -} from "../utils"; +} from "../utils/index.js"; import axios, { AxiosError } from "axios"; -import createHttpError, { HttpError } from "http-errors"; -import { load, CheerioAPI } from "cheerio"; -import { ScrapedAnimeEpisodes } from "../models/parsers"; +import { load, type CheerioAPI } from "cheerio"; +import createHttpError, { type HttpError } from "http-errors"; +import { type ScrapedAnimeEpisodes } from "../models/parsers/index.js"; // /anime/episodes/${anime-id} async function scrapeAnimeEpisodes( diff --git a/src/parsers/animeGenre.ts b/src/parsers/animeGenre.ts index 86470bb..e5efa1a 100644 --- a/src/parsers/animeGenre.ts +++ b/src/parsers/animeGenre.ts @@ -1,16 +1,15 @@ -import axios, { AxiosError } from "axios"; -import createHttpError, { HttpError } from "http-errors"; -import { load, CheerioAPI, SelectorType } from "cheerio"; - import { SRC_BASE_URL, ACCEPT_HEADER, + extractAnimes, USER_AGENT_HEADER, ACCEPT_ENCODING_HEADER, extractMostPopularAnimes, - extractAnimes, -} from "../utils"; -import { ScrapedGenreAnime } from "../models/parsers"; +} from "../utils/index.js"; +import axios, { AxiosError } from "axios"; +import createHttpError, { type HttpError } from "http-errors"; +import { load, type CheerioAPI, type SelectorType } from "cheerio"; +import type { ScrapedGenreAnime } from "../models/parsers/index.js"; // /anime/genre/${name}?page=${page} async function scrapeGenreAnime( diff --git a/src/parsers/animeProducer.ts b/src/parsers/animeProducer.ts index 8274843..2918936 100644 --- a/src/parsers/animeProducer.ts +++ b/src/parsers/animeProducer.ts @@ -1,7 +1,3 @@ -import axios, { AxiosError } from "axios"; -import createHttpError, { HttpError } from "http-errors"; -import { load, CheerioAPI, SelectorType } from "cheerio"; - import { SRC_BASE_URL, ACCEPT_HEADER, @@ -10,8 +6,11 @@ import { extractMostPopularAnimes, extractAnimes, extractTop10Animes, -} from "../utils"; -import { ScrapedProducerAnime } from "../models/parsers"; +} from "../utils/index.js"; +import axios, { AxiosError } from "axios"; +import createHttpError, { type HttpError } from "http-errors"; +import { load, type CheerioAPI, type SelectorType } from "cheerio"; +import type { ScrapedProducerAnime } from "../models/parsers/index.js"; // /anime/producer/${name}?page=${page} async function scrapeProducerAnimes( diff --git a/src/parsers/animeSearch.ts b/src/parsers/animeSearch.ts index 2656d35..3118150 100644 --- a/src/parsers/animeSearch.ts +++ b/src/parsers/animeSearch.ts @@ -1,5 +1,3 @@ -import axios, { AxiosError } from "axios"; -import { load, CheerioAPI, SelectorType } from "cheerio"; import { SRC_SEARCH_URL, ACCEPT_HEADER, @@ -7,10 +5,11 @@ import { ACCEPT_ENCODING_HEADER, extractMostPopularAnimes, extractAnimes, -} from "../utils"; - -import createHttpError, { HttpError } from "http-errors"; -import { ScrapedAnimeSearchResult } from "../models/parsers"; +} from "../utils/index.js"; +import axios, { AxiosError } from "axios"; +import createHttpError, { type HttpError } from "http-errors"; +import { load, type CheerioAPI, type SelectorType } from "cheerio"; +import type { ScrapedAnimeSearchResult } from "../models/parsers/index.js"; // /anime/search?q=${query}&page=${page} async function scrapeAnimeSearch( diff --git a/src/parsers/animeSearchSuggestion.ts b/src/parsers/animeSearchSuggestion.ts index 6fb8242..cc518ca 100644 --- a/src/parsers/animeSearchSuggestion.ts +++ b/src/parsers/animeSearchSuggestion.ts @@ -1,14 +1,13 @@ -import axios, { AxiosError } from "axios"; -import { load, CheerioAPI, SelectorType } from "cheerio"; import { SRC_HOME_URL, SRC_AJAX_URL, USER_AGENT_HEADER, ACCEPT_ENCODING_HEADER, -} from "../utils"; - -import createHttpError, { HttpError } from "http-errors"; -import { ScrapedAnimeSearchSuggestion } from "../models/parsers"; +} from "../utils/index.js"; +import axios, { AxiosError } from "axios"; +import createHttpError, { type HttpError } from "http-errors"; +import { load, type CheerioAPI, type SelectorType } from "cheerio"; +import type { ScrapedAnimeSearchSuggestion } from "../models/parsers/index.js"; // /anime/search/suggest?q=${query} async function scrapeAnimeSearchSuggestion( diff --git a/src/parsers/episodeServers.ts b/src/parsers/episodeServers.ts index 5e5ee00..b96ff18 100644 --- a/src/parsers/episodeServers.ts +++ b/src/parsers/episodeServers.ts @@ -4,11 +4,11 @@ import { ACCEPT_HEADER, USER_AGENT_HEADER, ACCEPT_ENCODING_HEADER, -} from "../utils"; +} from "../utils/index.js"; import axios, { AxiosError } from "axios"; -import createHttpError, { HttpError } from "http-errors"; -import { load, CheerioAPI, SelectorType } from "cheerio"; -import { ScrapedEpisodeServers } from "../models/parsers"; +import createHttpError, { type HttpError } from "http-errors"; +import { load, type CheerioAPI, type SelectorType } from "cheerio"; +import type { ScrapedEpisodeServers } from "../models/parsers/index.js"; // /anime/servers?episodeId=${id} async function scrapeEpisodeServers( diff --git a/src/parsers/homePage.ts b/src/parsers/homePage.ts index 4920145..d3a231a 100644 --- a/src/parsers/homePage.ts +++ b/src/parsers/homePage.ts @@ -1,5 +1,3 @@ -import axios, { AxiosError } from "axios"; -import { load, CheerioAPI, SelectorType } from "cheerio"; import { SRC_HOME_URL, ACCEPT_HEADER, @@ -7,10 +5,11 @@ import { ACCEPT_ENCODING_HEADER, extractTop10Animes, extractAnimes, -} from "../utils"; - -import createHttpError, { HttpError } from "http-errors"; -import { ScrapedHomePage } from "../models/parsers"; +} from "../utils/index.js"; +import axios, { AxiosError } from "axios"; +import createHttpError, { type HttpError } from "http-errors"; +import type { ScrapedHomePage } from "../models/parsers/index.js"; +import { load, type CheerioAPI, type SelectorType } from "cheerio"; // /anime/home async function scrapeHomePage(): Promise { -- cgit v1.2.3