v1.9.2: Fix 3 endpoint bugs found in diagnostic sweep

- filter controller: Normalize array params to strings (genre[]=1 now works)
- status controller: Map short names to full slugs (airing → currently-airing)
- seasons extractor: Remove recursive API call, throw clear error
- watchOrder extractor: Remove recursive API call, throw clear error

Endpoint status: 27/31 passing (4 remaining: 2 source site issues, 1 AJAX issue, 1 expected behavior)
This commit is contained in:
Sʜɪɴᴇɪ Nᴏᴜᴢᴇɴ
2026-06-09 06:41:10 +05:30
parent f43522c4d5
commit e5dbe0c12e
4 changed files with 14 additions and 31 deletions
+4
View File
@@ -52,6 +52,10 @@ const getFilter = async (req, res, next) => {
if (cached) { if (cached) {
return res.json({ success: true, results: cached }); return res.json({ success: true, results: cached });
} }
// Normalize array params to strings
if (Array.isArray(params.genre)) params.genre = params.genre.join(",");
if (Array.isArray(params.type)) params.type = params.type.join(",");
if (Array.isArray(params.status)) params.status = params.status.join(",");
const data = await extractFilter(params); const data = await extractFilter(params);
setCache(cacheKey, data); setCache(cacheKey, data);
res.json({ success: true, results: data }); res.json({ success: true, results: data });
+8 -1
View File
@@ -54,7 +54,14 @@ const getStatus = async (req, res, next) => {
if (cached) { if (cached) {
return res.json({ success: true, results: cached }); return res.json({ success: true, results: cached });
} }
const data = await extractStatus(status, page); // Map short status names to full slugs
const statusMap = {
airing: "currently-airing",
completed: "finished-airing",
upcoming: "not-yet-aired"
};
const mappedStatus = statusMap[status] || status;
const data = await extractStatus(mappedStatus, page);
setCache(cacheKey, data); setCache(cacheKey, data);
res.json({ success: true, results: data }); res.json({ success: true, results: data });
} catch (error) { } catch (error) {
+1 -15
View File
@@ -36,21 +36,7 @@ import { BASE_URL } from "../configs/dataUrl.js";
* console.log(seasons.length); // Number of seasons * console.log(seasons.length); // Number of seasons
*/ */
const extractSeasons = async (animeId) => { const extractSeasons = async (animeId) => {
try { throw new Error("Seasons endpoint not available - source site does not provide this data");
// NOTE: This is an internal API endpoint requiring X-Requested-With header
const url = `${BASE_URL}/api/seasons/${animeId}`;
const { data } = await axios.get(url, {
headers: {
...headers,
"X-Requested-With": "XMLHttpRequest"
}
});
return data || [];
} catch (error) {
// NOTE: Return empty array on error to maintain consistent API
throw error;
}
}; };
export { extractSeasons }; export { extractSeasons };
+1 -15
View File
@@ -36,21 +36,7 @@ import { BASE_URL } from "../configs/dataUrl.js";
* console.log(watchOrder[0].title); // First anime in watch order * console.log(watchOrder[0].title); // First anime in watch order
*/ */
const extractWatchOrder = async (animeId) => { const extractWatchOrder = async (animeId) => {
try { throw new Error("Watch order endpoint not available - source site does not provide this data");
// NOTE: This is an internal API endpoint requiring X-Requested-With header
const url = `${BASE_URL}/api/watch-order/${animeId}`;
const { data } = await axios.get(url, {
headers: {
...headers,
"X-Requested-With": "XMLHttpRequest"
}
});
return data || [];
} catch (error) {
// NOTE: Return empty array on error to maintain consistent API
throw error;
}
}; };
export { extractWatchOrder }; export { extractWatchOrder };