refactor: integrate new getOrSet method definition

This commit is contained in:
Ritesh Ghosh
2024-12-22 00:43:18 +05:30
parent 64eaa18ed9
commit b26a9cd9ff
+12 -12
View File
@@ -14,8 +14,8 @@ hianimeRouter.get("/home", async (c) => {
const cacheConfig = c.get("CACHE_CONFIG"); const cacheConfig = c.get("CACHE_CONFIG");
const data = await cache.getOrSet<HiAnime.ScrapedHomePage>( const data = await cache.getOrSet<HiAnime.ScrapedHomePage>(
cacheConfig.key,
hianime.getHomePage, hianime.getHomePage,
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -33,8 +33,8 @@ hianimeRouter.get("/azlist/:sortOption", async (c) => {
Number(decodeURIComponent(c.req.query("page") || "")) || 1; Number(decodeURIComponent(c.req.query("page") || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedAnimeAZList>( const data = await cache.getOrSet<HiAnime.ScrapedAnimeAZList>(
cacheConfig.key,
async () => hianime.getAZList(sortOption, page), async () => hianime.getAZList(sortOption, page),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -51,8 +51,8 @@ hianimeRouter.get("/category/:name", async (c) => {
Number(decodeURIComponent(c.req.query("page") || "")) || 1; Number(decodeURIComponent(c.req.query("page") || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedAnimeCategory>( const data = await cache.getOrSet<HiAnime.ScrapedAnimeCategory>(
cacheConfig.key,
async () => hianime.getCategoryAnime(categoryName, page), async () => hianime.getCategoryAnime(categoryName, page),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -67,8 +67,8 @@ hianimeRouter.get("/genre/:name", async (c) => {
Number(decodeURIComponent(c.req.query("page") || "")) || 1; Number(decodeURIComponent(c.req.query("page") || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedGenreAnime>( const data = await cache.getOrSet<HiAnime.ScrapedGenreAnime>(
cacheConfig.key,
async () => hianime.getGenreAnime(genreName, page), async () => hianime.getGenreAnime(genreName, page),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -83,8 +83,8 @@ hianimeRouter.get("/producer/:name", async (c) => {
Number(decodeURIComponent(c.req.query("page") || "")) || 1; Number(decodeURIComponent(c.req.query("page") || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedProducerAnime>( const data = await cache.getOrSet<HiAnime.ScrapedProducerAnime>(
cacheConfig.key,
async () => hianime.getProducerAnimes(producerName, page), async () => hianime.getProducerAnimes(producerName, page),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -97,8 +97,8 @@ hianimeRouter.get("/schedule", async (c) => {
const date = decodeURIComponent(c.req.query("date") || ""); const date = decodeURIComponent(c.req.query("date") || "");
const data = await cache.getOrSet<HiAnime.ScrapedEstimatedSchedule>( const data = await cache.getOrSet<HiAnime.ScrapedEstimatedSchedule>(
cacheConfig.key,
async () => hianime.getEstimatedSchedule(date), async () => hianime.getEstimatedSchedule(date),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -114,8 +114,8 @@ hianimeRouter.get("/search", async (c) => {
const pageNo = Number(decodeURIComponent(page || "")) || 1; const pageNo = Number(decodeURIComponent(page || "")) || 1;
const data = await cache.getOrSet<HiAnime.ScrapedAnimeSearchResult>( const data = await cache.getOrSet<HiAnime.ScrapedAnimeSearchResult>(
cacheConfig.key,
async () => hianime.search(query, pageNo, filters), async () => hianime.search(query, pageNo, filters),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -128,8 +128,8 @@ hianimeRouter.get("/search/suggestion", async (c) => {
const query = decodeURIComponent(c.req.query("q") || ""); const query = decodeURIComponent(c.req.query("q") || "");
const data = await cache.getOrSet<HiAnime.ScrapedAnimeSearchSuggestion>( const data = await cache.getOrSet<HiAnime.ScrapedAnimeSearchSuggestion>(
cacheConfig.key,
async () => hianime.searchSuggestions(query), async () => hianime.searchSuggestions(query),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -142,8 +142,8 @@ hianimeRouter.get("/anime/:animeId", async (c) => {
const animeId = decodeURIComponent(c.req.param("animeId").trim()); const animeId = decodeURIComponent(c.req.param("animeId").trim());
const data = await cache.getOrSet<HiAnime.ScrapedAnimeAboutInfo>( const data = await cache.getOrSet<HiAnime.ScrapedAnimeAboutInfo>(
cacheConfig.key,
async () => hianime.getInfo(animeId), async () => hianime.getInfo(animeId),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -158,8 +158,8 @@ hianimeRouter.get("/episode/servers", async (c) => {
); );
const data = await cache.getOrSet<HiAnime.ScrapedEpisodeServers>( const data = await cache.getOrSet<HiAnime.ScrapedEpisodeServers>(
cacheConfig.key,
async () => hianime.getEpisodeServers(animeEpisodeId), async () => hianime.getEpisodeServers(animeEpisodeId),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -182,8 +182,8 @@ hianimeRouter.get("/episode/sources", async (c) => {
| "raw"; | "raw";
const data = await cache.getOrSet<HiAnime.ScrapedAnimeEpisodesSources>( const data = await cache.getOrSet<HiAnime.ScrapedAnimeEpisodesSources>(
cacheConfig.key,
async () => hianime.getEpisodeSources(animeEpisodeId, server, category), async () => hianime.getEpisodeSources(animeEpisodeId, server, category),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );
@@ -196,8 +196,8 @@ hianimeRouter.get("/anime/:animeId/episodes", async (c) => {
const animeId = decodeURIComponent(c.req.param("animeId").trim()); const animeId = decodeURIComponent(c.req.param("animeId").trim());
const data = await cache.getOrSet<HiAnime.ScrapedAnimeEpisodes>( const data = await cache.getOrSet<HiAnime.ScrapedAnimeEpisodes>(
cacheConfig.key,
async () => hianime.getEpisodes(animeId), async () => hianime.getEpisodes(animeId),
cacheConfig.key,
cacheConfig.duration cacheConfig.duration
); );