aboutsummaryrefslogtreecommitdiff
path: root/pages/api
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api')
-rw-r--r--pages/api/v2/episode/[id].js14
-rw-r--r--pages/api/v2/etc/recent/[page].js4
-rw-r--r--pages/api/v2/info/index.js7
-rw-r--r--pages/api/v2/source/index.js6
4 files changed, 13 insertions, 18 deletions
diff --git a/pages/api/v2/episode/[id].js b/pages/api/v2/episode/[id].js
index 029d131..ea511e6 100644
--- a/pages/api/v2/episode/[id].js
+++ b/pages/api/v2/episode/[id].js
@@ -4,8 +4,8 @@ import appendMetaToEpisodes from "@/utils/appendMetaToEpisodes";
let CONSUMET_URI;
-CONSUMET_URI = process.env.API_URI;
-if (CONSUMET_URI.endsWith("/")) {
+CONSUMET_URI = process.env.API_URI || null;
+if (CONSUMET_URI && CONSUMET_URI.endsWith("/")) {
CONSUMET_URI = CONSUMET_URI.slice(0, -1);
}
@@ -96,13 +96,7 @@ async function fetchConsumet(id) {
async function fetchAnify(id) {
try {
- if (!process.env.API_KEY) {
- return [];
- }
-
- const { data } = await axios.get(
- `https://api.anify.tv/episodes/${id}?apikey=${API_KEY}`
- );
+ const { data } = await axios.get(`https://api.anify.tv/episodes/${id}`);
if (!data) {
return [];
@@ -138,7 +132,7 @@ async function fetchCoverImage(id, available = false) {
}
const { data } = await axios.get(
- `https://api.anify.tv/content-metadata/${id}?apikey=${API_KEY}`
+ `https://api.anify.tv/content-metadata/${id}`
);
if (!data) {
diff --git a/pages/api/v2/etc/recent/[page].js b/pages/api/v2/etc/recent/[page].js
index b1bda0f..e21c38e 100644
--- a/pages/api/v2/etc/recent/[page].js
+++ b/pages/api/v2/etc/recent/[page].js
@@ -1,8 +1,8 @@
import { rateLimiterRedis, redis } from "@/lib/redis";
let API_URL;
-API_URL = process.env.API_URI;
-if (API_URL.endsWith("/")) {
+API_URL = process.env.API_URI || null;
+if (API_URL && API_URL.endsWith("/")) {
API_URL = API_URL.slice(0, -1);
}
diff --git a/pages/api/v2/info/index.js b/pages/api/v2/info/index.js
index 39795d3..4bebfae 100644
--- a/pages/api/v2/info/index.js
+++ b/pages/api/v2/info/index.js
@@ -7,7 +7,7 @@ export async function fetchInfo(id) {
try {
// console.log(id);
const { data } = await axios
- .get(`https://api.anify.tv/info/${id}?apikey=${API_KEY}`)
+ .get(`https://api.anify.tv/info/${id}`)
.catch((err) => {
return {
data: null,
@@ -19,7 +19,7 @@ export async function fetchInfo(id) {
}
const { data: Chapters } = await axios.get(
- `https://api.anify.tv/chapters/${data.id}?apikey=${API_KEY}`
+ `https://api.anify.tv/chapters/${data.id}`
);
if (!Chapters) {
@@ -53,7 +53,8 @@ export default async function handler(req, res) {
return res.status(404).json({ error: "Manga not found" });
}
- if (redis) 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) {
diff --git a/pages/api/v2/source/index.js b/pages/api/v2/source/index.js
index 9ec6082..103bc29 100644
--- a/pages/api/v2/source/index.js
+++ b/pages/api/v2/source/index.js
@@ -2,8 +2,8 @@ import { rateLimiterRedis, redis } from "@/lib/redis";
import axios from "axios";
let CONSUMET_URI;
-CONSUMET_URI = process.env.API_URI;
-if (CONSUMET_URI.endsWith("/")) {
+CONSUMET_URI = process.env.API_URI || null;
+if (CONSUMET_URI && CONSUMET_URI.endsWith("/")) {
CONSUMET_URI = CONSUMET_URI.slice(0, -1);
}
const API_KEY = process.env.API_KEY;
@@ -25,7 +25,7 @@ async function anifySource(providerId, watchId, episode, id, sub) {
const { data } = await axios.get(
`https://api.anify.tv/sources?providerId=${providerId}&watchId=${encodeURIComponent(
watchId
- )}&episodeNumber=${episode}&id=${id}&subType=${sub}&apikey=${API_KEY}`
+ )}&episodeNumber=${episode}&id=${id}&subType=${sub}`
);
return data;
} catch (error) {