refactor: replace amvstrm source with aniwatch
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
export async function fetchSearchResultsFromAmvstrm(
|
||||
query: string,
|
||||
page: number,
|
||||
limit: number,
|
||||
) {
|
||||
return fetch(
|
||||
`https://amvstrm.up.railway.app/api/v2/search?q=${query}&p=${page}&limit=${limit}`,
|
||||
)
|
||||
.then((res) => res.json<any>())
|
||||
.then(({ pageInfo: { hasNextPage }, results }) => ({
|
||||
hasNextPage,
|
||||
results: results.map(
|
||||
({
|
||||
id,
|
||||
title: { userPreferred, english },
|
||||
coverImage: { extraLarge, large, medium },
|
||||
}: any) => ({
|
||||
id,
|
||||
title: { userPreferred, english },
|
||||
coverImage: { extraLarge, large, medium },
|
||||
}),
|
||||
),
|
||||
}))
|
||||
.then((searchResults) => {
|
||||
if (searchResults.results.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return searchResults;
|
||||
});
|
||||
}
|
||||
@@ -12,12 +12,6 @@ describe('requests the "/search" route', () => {
|
||||
expect(response.json()).resolves.toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("valid query that returns amvstrm results", async () => {
|
||||
const response = await app.request("/search?query=amvstrm");
|
||||
|
||||
expect(response.json()).resolves.toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("query that returns no results", async () => {
|
||||
const response = await app.request("/search?query=a");
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
||||
import { fetchFromMultipleSources } from "~/libs/fetchFromMultipleSources";
|
||||
import { PaginatedResponseSchema } from "~/types/schema";
|
||||
|
||||
import { fetchSearchResultsFromAmvstrm } from "./amvstrm";
|
||||
import { fetchSearchResultsFromAnilist } from "./anilist";
|
||||
import { SearchResult } from "./searchResult";
|
||||
|
||||
@@ -41,7 +40,6 @@ app.openapi(route, async (c) => {
|
||||
|
||||
const { result: response, errorOccurred } = await fetchFromMultipleSources([
|
||||
() => fetchSearchResultsFromAnilist(query, page, limit),
|
||||
() => fetchSearchResultsFromAmvstrm(query, page, limit),
|
||||
]);
|
||||
|
||||
if (!response) {
|
||||
|
||||
Reference in New Issue
Block a user