diff --git a/src/scripts/fetch-data/fetch-query.ts b/src/scripts/fetch-data/fetch-query.ts deleted file mode 100644 index 0b43f56..0000000 --- a/src/scripts/fetch-data/fetch-query.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2021 MillenniumEarl -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -"use strict"; - -// Modules from files -import fetchHandiworkURLs from "./fetch-handiwork"; -import fetchLatestHandiworkURLs from "./fetch-latest"; -import fetchThreadHandiworkURLs from "./fetch-thread"; -import HandiworkSearchQuery from "../classes/query/handiwork-search-query"; -import LatestSearchQuery from "../classes/query/latest-search-query"; -import ThreadSearchQuery from "../classes/query/thread-search-query"; -import { IQuery } from "../interfaces"; - -//#region Public methods - -/** - * @param query Query used for the search - * @param limit Maximum number of items to get. Default: 30 - * @returns URLs of the fetched games - */ -export default async function getURLsFromQuery( - query: IQuery, - limit = 30 -): Promise { - switch (query.itype) { - case "HandiworkSearchQuery": - return fetchHandiworkURLs(query as HandiworkSearchQuery, limit); - case "LatestSearchQuery": - return fetchLatestHandiworkURLs(query as LatestSearchQuery, limit); - case "ThreadSearchQuery": - return fetchThreadHandiworkURLs(query as ThreadSearchQuery, limit); - default: - throw Error(`Invalid query type: ${query.itype}`); - } -} - -//#endregion diff --git a/src/scripts/search.ts b/src/scripts/search.ts index e74fbfc..8f8813e 100644 --- a/src/scripts/search.ts +++ b/src/scripts/search.ts @@ -9,7 +9,10 @@ // Modules from file import { IBasic, IQuery } from "./interfaces"; import getHandiworkInformation from "./scrape-data/handiwork-parse"; -import getURLsFromQuery from "./fetch-data/fetch-query"; +import { HandiworkSearchQuery, LatestSearchQuery, ThreadSearchQuery } from ".."; +import fetchHandiworkURLs from "./fetch-data/fetch-handiwork"; +import fetchLatestHandiworkURLs from "./fetch-data/fetch-latest"; +import fetchThreadHandiworkURLs from "./fetch-data/fetch-thread"; /** * Gets the handiworks that match the passed parameters. @@ -29,3 +32,25 @@ export default async function search( return Promise.all(results); } + +//#region Private methods + +/** + * @param query Query used for the search + * @param limit Maximum number of items to get. Default: 30 + * @returns URLs of the fetched games + */ +async function getURLsFromQuery(query: IQuery, limit = 30): Promise { + switch (query.itype) { + case "HandiworkSearchQuery": + return fetchHandiworkURLs(query as HandiworkSearchQuery, limit); + case "LatestSearchQuery": + return fetchLatestHandiworkURLs(query as LatestSearchQuery, limit); + case "ThreadSearchQuery": + return fetchThreadHandiworkURLs(query as ThreadSearchQuery, limit); + default: + throw Error(`Invalid query type: ${query.itype}`); + } +} + +//#endregion Private methods