aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRitesh Ghosh <[email protected]>2024-12-22 00:43:18 +0530
committerRitesh Ghosh <[email protected]>2024-12-22 00:43:18 +0530
commitb26a9cd9ff496bf9bad2a19d9a107fba20ce8791 (patch)
treed7f853dbb64f1d8548b682dc5bc66ec16a19f35d
parent64eaa18ed9f87c7fb07377762d11e8f2048bd8d8 (diff)
downloadaniwatch-api-b26a9cd9ff496bf9bad2a19d9a107fba20ce8791.tar.xz
aniwatch-api-b26a9cd9ff496bf9bad2a19d9a107fba20ce8791.zip
refactor: integrate new `getOrSet` method definition
-rw-r--r--src/routes/hianime.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/routes/hianime.ts b/src/routes/hianime.ts
index e636a5e..04be1bb 100644
--- a/src/routes/hianime.ts
+++ b/src/routes/hianime.ts
@@ -14,8 +14,8 @@ hianimeRouter.get("/home", async (c) => {
const cacheConfig = c.get("CACHE_CONFIG");
const data = await cache.getOrSet<HiAnime.ScrapedHomePage>(
- cacheConfig.key,
hianime.getHomePage,
+ cacheConfig.key,
cacheConfig.duration
);
@@ -33,8 +33,8 @@ hianimeRouter.get("/azlist/:sortOption", async (c) => {
Number(decodeURIComponent(c.req.query("page") || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedAnimeAZList>(
- cacheConfig.key,
async () => hianime.getAZList(sortOption, page),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -51,8 +51,8 @@ hianimeRouter.get("/category/:name", async (c) => {
Number(decodeURIComponent(c.req.query("page") || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedAnimeCategory>(
- cacheConfig.key,
async () => hianime.getCategoryAnime(categoryName, page),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -67,8 +67,8 @@ hianimeRouter.get("/genre/:name", async (c) => {
Number(decodeURIComponent(c.req.query("page") || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedGenreAnime>(
- cacheConfig.key,
async () => hianime.getGenreAnime(genreName, page),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -83,8 +83,8 @@ hianimeRouter.get("/producer/:name", async (c) => {
Number(decodeURIComponent(c.req.query("page") || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedProducerAnime>(
- cacheConfig.key,
async () => hianime.getProducerAnimes(producerName, page),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -97,8 +97,8 @@ hianimeRouter.get("/schedule", async (c) => {
const date = decodeURIComponent(c.req.query("date") || "");
const data = await cache.getOrSet<HiAnime.ScrapedEstimatedSchedule>(
- cacheConfig.key,
async () => hianime.getEstimatedSchedule(date),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -114,8 +114,8 @@ hianimeRouter.get("/search", async (c) => {
const pageNo = Number(decodeURIComponent(page || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedAnimeSearchResult>(
- cacheConfig.key,
async () => hianime.search(query, pageNo, filters),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -128,8 +128,8 @@ hianimeRouter.get("/search/suggestion", async (c) => {
const query = decodeURIComponent(c.req.query("q") || "");
const data = await cache.getOrSet<HiAnime.ScrapedAnimeSearchSuggestion>(
- cacheConfig.key,
async () => hianime.searchSuggestions(query),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -142,8 +142,8 @@ hianimeRouter.get("/anime/:animeId", async (c) => {
const animeId = decodeURIComponent(c.req.param("animeId").trim());
const data = await cache.getOrSet<HiAnime.ScrapedAnimeAboutInfo>(
- cacheConfig.key,
async () => hianime.getInfo(animeId),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -158,8 +158,8 @@ hianimeRouter.get("/episode/servers", async (c) => {
);
const data = await cache.getOrSet<HiAnime.ScrapedEpisodeServers>(
- cacheConfig.key,
async () => hianime.getEpisodeServers(animeEpisodeId),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -182,8 +182,8 @@ hianimeRouter.get("/episode/sources", async (c) => {
| "raw";
const data = await cache.getOrSet<HiAnime.ScrapedAnimeEpisodesSources>(
- cacheConfig.key,
async () => hianime.getEpisodeSources(animeEpisodeId, server, category),
+ cacheConfig.key,
cacheConfig.duration
);
@@ -196,8 +196,8 @@ hianimeRouter.get("/anime/:animeId/episodes", async (c) => {
const animeId = decodeURIComponent(c.req.param("animeId").trim());
const data = await cache.getOrSet<HiAnime.ScrapedAnimeEpisodes>(
- cacheConfig.key,
async () => hianime.getEpisodes(animeId),
+ cacheConfig.key,
cacheConfig.duration
);