aboutsummaryrefslogtreecommitdiff
path: root/pages/api
diff options
context:
space:
mode:
authorArtrix <[email protected]>2024-01-05 05:12:52 -0800
committerGitHub <[email protected]>2024-01-05 20:12:52 +0700
commit553fe1c71082b040e9f9667ad3e99acdb33990b2 (patch)
tree0c770c406c8ff934ce34d8b10dbae948a554a619 /pages/api
parentmigrate to typescript (diff)
downloadmoopa-553fe1c71082b040e9f9667ad3e99acdb33990b2.tar.xz
moopa-553fe1c71082b040e9f9667ad3e99acdb33990b2.zip
feat: Implement a way to review/rate anime (#108)
* Make details cover lead back to anime page * Make 'markProgress' use object instead of param list * Import Link * Implement Rate modal * Pass session into useAniList Co-authored-by: Factiven <[email protected]> * Reimplement using markComplete & add toast for failure * redefined ratemodal * fix: home page client error * update version --------- Co-authored-by: Factiven <[email protected]>
Diffstat (limited to 'pages/api')
-rw-r--r--pages/api/v2/episode/[id].tsx16
-rw-r--r--pages/api/v2/etc/recent/[page].tsx2
2 files changed, 4 insertions, 14 deletions
diff --git a/pages/api/v2/episode/[id].tsx b/pages/api/v2/episode/[id].tsx
index b646126..ddf5635 100644
--- a/pages/api/v2/episode/[id].tsx
+++ b/pages/api/v2/episode/[id].tsx
@@ -139,10 +139,6 @@ async function fetchAnify(id?: string) {
async function fetchCoverImage(id: string, available = false) {
try {
- if (!process.env.API_KEY) {
- return [];
- }
-
if (available) {
return null;
}
@@ -171,10 +167,10 @@ export default async function handler(
) {
const { id, releasing = "false", dub = false, refresh = null } = req.query;
- // if releasing is true then cache for 1 hour, if it false cache for 1 month;
+ // if releasing is true then cache for 3 hour, if it false cache for 1 month;
let cacheTime = null;
if (releasing === "true") {
- cacheTime = 60 * 60; // 1 hour
+ cacheTime = 60 * 60 * 3; // 3 hours
} else if (releasing === "false") {
cacheTime = 60 * 60 * 24 * 30; // 1 month
}
@@ -210,7 +206,7 @@ export default async function handler(
meta = null;
}
- if (refresh) {
+ if (refresh !== null) {
await redis.del(`episode:${id}`);
} else {
cached = await redis.get(`episode:${id}`);
@@ -262,12 +258,6 @@ export default async function handler(
fetchCoverImage(id, meta),
]);
- // const hasImage = consumet.map((i) =>
- // i.episodes?.sub?.some(
- // (e) => e.img !== null || !e.img.includes("https://s4.anilist.co/")
- // )
- // );
-
let subDub = "sub";
if (dub) {
subDub = "dub";
diff --git a/pages/api/v2/etc/recent/[page].tsx b/pages/api/v2/etc/recent/[page].tsx
index e49591c..4e3bc98 100644
--- a/pages/api/v2/etc/recent/[page].tsx
+++ b/pages/api/v2/etc/recent/[page].tsx
@@ -1,5 +1,5 @@
import { rateLimitStrict, redis } from "@/lib/redis";
-import { AnifyRecentEpisode } from "@/utils/types";
+import { AnifyRecentEpisode } from "types";
import axios from "axios";
import { NextApiRequest, NextApiResponse } from "next";