refactor: Replace generic AnilistDurableObject fetch endpoint with dedicated methods and update their usage.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user