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,45 @@
import { env } from "cloudflare:workers";
import { graphql } from "gql.tada";
import { GraphQLError } from "graphql";
import type { GraphQLContext } from "~/graph~/context";
import { MediaFragment } from "~/types/title/mediaFragment";
enum HomeCategory {
WATCHING,
PLANNING,
}
export async function home(
_parent: any,
args: { category: HomeCategory; page?: number },
context: GraphQLContext,
) {
const { category, page = 1 } = args;
const { user, aniListToken } = context;
let statusFilters: string[] = [];
switch (category) {
case HomeCategory.WATCHING:
statusFilters = ["CURRENT"];
break;
case HomeCategory.PLANNING:
statusFilters = ["PLANNING", "PAUSED", "REPEATING"];
break;
}
const stub = await env.ANILIST_DO.getByName("GLOBAL");
const response = await stub.getTitles(
user?.name,
page,
statusFilters,
aniListToken,
);
if (!response) {
throw new GraphQLError(`Failed to fetch ${category} titles`, {
extensions: { code: "INTERNAL_SERVER_ERROR" },
});
}
return response;
}