From e11decdd520c3fcaef916d3899fbb005153fc869 Mon Sep 17 00:00:00 2001 From: Aijazmakerb <786aijazusmaan@gmail.com> Date: Fri, 20 Oct 2023 17:12:14 +0530 Subject: [PATCH 1/4] fixed schedules --- pages/api/v2/etc/schedule/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pages/api/v2/etc/schedule/index.js b/pages/api/v2/etc/schedule/index.js index 9b8f43d9..2ddc82a2 100644 --- a/pages/api/v2/etc/schedule/index.js +++ b/pages/api/v2/etc/schedule/index.js @@ -2,13 +2,11 @@ import axios from "axios"; import cron from "cron"; import { rateLimiterRedis, redis } from "@/lib/redis"; -const API_KEY = process.env.API_KEY; - // Function to fetch new data async function fetchData() { try { const { data } = await axios.get( - `https://api.anify.tv/schedule?apikey=${API_KEY}` + `https://api.anify.tv/schedule?fields=[id,coverImage,title,bannerImage]` ); return data; } catch (error) { From dbc21709d83b5aa16219be73ea2b21eafb569331 Mon Sep 17 00:00:00 2001 From: A i j a Z <72906651+Aijazmakerb@users.noreply.github.com> Date: Sun, 22 Oct 2023 20:17:17 +0530 Subject: [PATCH 2/4] fixed redis --- pages/api/v2/episode/[id].js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/api/v2/episode/[id].js b/pages/api/v2/episode/[id].js index 3f1372b8..b86a1983 100644 --- a/pages/api/v2/episode/[id].js +++ b/pages/api/v2/episode/[id].js @@ -238,7 +238,7 @@ export default async function handler(req, res) { if (meta) { data = await appendMetaToEpisodes(filteredData, JSON.parse(meta)); } else if (cover && !cover.some((e) => e.img === null)) { - await redis.set(`meta:${id}`, JSON.stringify(cover)); + if (redis) await redis.set(`meta:${id}`, JSON.stringify(cover)); data = await appendMetaToEpisodes(filteredData, cover); } From ae4b1fba6ea57d6ccd3f74b44f3ed5aa642a5541 Mon Sep 17 00:00:00 2001 From: A i j a Z <72906651+Aijazmakerb@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:42:07 +0530 Subject: [PATCH 3/4] Update [...id].js --- pages/en/manga/[...id].js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/pages/en/manga/[...id].js b/pages/en/manga/[...id].js index 106bce2e..6d2b0164 100644 --- a/pages/en/manga/[...id].js +++ b/pages/en/manga/[...id].js @@ -347,14 +347,14 @@ export async function getServerSideProps(context) { }, }; } else { - const getCached = await redis.get(`mangaPage:${mangadexId}`); + if (redis) { + const getCached = await redis.get(`mangaPage:${mangadexId}`); - if (getCached) { - cached = JSON.parse(getCached); + if (getCached) { + cached = JSON.parse(getCached); + } } - // let chapters; - if (cached) { data = cached.data; info = cached.info; @@ -389,12 +389,15 @@ export async function getServerSideProps(context) { color: textColor, }; - await redis.set( - `mangaPage:${mangadexId}`, - JSON.stringify({ data, info, color }), - "ex", - 60 * 60 * 24 - ); + if(redis) + { + await redis.set( + `mangaPage:${mangadexId}`, + JSON.stringify({ data, info, color }), + "ex", + 60 * 60 * 24 + ); + } } } From 51bdb828847c0018280982acc4e408a310f9e3d0 Mon Sep 17 00:00:00 2001 From: A i j a Z <72906651+Aijazmakerb@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:43:17 +0530 Subject: [PATCH 4/4] Update index.js --- pages/api/v2/info/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pages/api/v2/info/index.js b/pages/api/v2/info/index.js index 95770bdb..39795d3b 100644 --- a/pages/api/v2/info/index.js +++ b/pages/api/v2/info/index.js @@ -39,10 +39,12 @@ export default async function handler(req, res) { try { let cached; // const data = await fetchInfo(id); - cached = await redis.get(`manga:${id}`); + if (redis) { + cached = await redis.get(`manga:${id}`); - if (cached) { - return res.status(200).json(JSON.parse(cached)); + if (cached) { + return res.status(200).json(JSON.parse(cached)); + } } const manga = await fetchInfo(id); @@ -51,7 +53,7 @@ export default async function handler(req, res) { return res.status(404).json({ error: "Manga not found" }); } - await redis.set(`manga:${id}`, JSON.stringify(manga), "ex", 60 * 60 * 24); + if (redis) await redis.set(`manga:${id}`, JSON.stringify(manga), "ex", 60 * 60 * 24); res.status(200).json(manga); } catch (error) {