refactor: cleaned up REST code
Some checks failed
Deploy / Deploy (push) Has been cancelled

also removed any references to Anify
This commit is contained in:
2025-12-06 10:00:26 -05:00
parent ec42ac4026
commit dbc78727bd
74 changed files with 300 additions and 8380 deletions

View File

@@ -0,0 +1,32 @@
import { GraphQLError } from "graphql";
import type { GraphQLContext } from "~/context";
import { fetchPopularTitlesFromAnilist } from "~/services/popular/category/anilist";
import type { PopularCategory } from "~/services/popular/category/enum";
interface PopularByCategoryArgs {
category: PopularCategory;
page?: number;
limit?: number;
}
export async function popularByCategory(
_parent: unknown,
args: PopularByCategoryArgs,
_context: GraphQLContext,
) {
const { category, page = 1, limit = 10 } = args;
const response = await fetchPopularTitlesFromAnilist(category, page, limit);
if (!response) {
throw new GraphQLError(`Failed to fetch ${category} titles`, {
extensions: { code: "INTERNAL_SERVER_ERROR" },
});
}
return {
results: response.results || [],
hasNextPage: response.hasNextPage ?? false,
};
}