diff --git a/src/controllers/search/anilist.ts b/src/controllers/search/anilist.ts index 55f57ea..0ea5dc8 100644 --- a/src/controllers/search/anilist.ts +++ b/src/controllers/search/anilist.ts @@ -41,7 +41,18 @@ export async function fetchSearchResultsFromAnilist( } const { media: results, pageInfo } = page; - return { results, hasNextPage: pageInfo?.hasNextPage }; + return { + results: results?.map((result) => { + if (!result) return null; + + return { + id: result.id, + title: result.title?.userPreferred ?? result.title?.english, + coverImage: result.coverImage, + }; + }), + hasNextPage: pageInfo?.hasNextPage, + }; }) .catch((err) => { const response = err.response; diff --git a/src/controllers/search/searchResult.ts b/src/controllers/search/searchResult.ts index d7dedc1..71f8b9f 100644 --- a/src/controllers/search/searchResult.ts +++ b/src/controllers/search/searchResult.ts @@ -1,13 +1,9 @@ import { z } from "@hono/zod-openapi"; +export type SearchResult = z.infer; export const SearchResult = z.object({ id: z.number().openapi({ type: "integer", format: "int64" }), - title: z.nullable( - z.object({ - userPreferred: z.nullable(z.string()), - english: z.nullable(z.string()), - }), - ), + title: z.nullable(z.string()), coverImage: z.nullable( z.object({ medium: z.nullable(z.string()).optional(),