refactor: Replace generic AnilistDurableObject fetch endpoint with dedicated methods and update their usage.

This commit is contained in:
2025-11-29 06:22:08 -05:00
parent b1e46ad6eb
commit 25f5f80696
13 changed files with 869 additions and 655 deletions

View File

@@ -30,27 +30,12 @@ export async function getUpcomingTitlesFromAnilist(req: HonoRequest) {
let shouldContinue = true;
do {
const response = await stub.fetch("http://anilist-do/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
operationName: "GetUpcomingTitles",
variables: {
page: currentPage++,
airingAtLowerBound: lastCheckedScheduleAt,
airingAtUpperBound: twoDaysFromNow,
},
}),
});
const Page = await stub.getUpcomingTitles(
currentPage++,
lastCheckedScheduleAt,
twoDaysFromNow,
);
if (!response.ok) {
// If failed, break loop or handle error. For now, break.
break;
}
const Page = (await response.json()) as any;
if (!Page) break;
const { airingSchedules, pageInfo } = Page;