mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 10:55:10 +00:00
feat: add complete API endpoints for full website
- Add /api/watch endpoint for watch page data - Add /api/az-list for alphabetical browsing - Add /api/new-release and /api/newly-added - Add /api/status for ongoing/completed lists - Add /api/trending-sidebar for sidebar data - Update README with all new endpoints - Update CHANGELOG
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { extractWatchPage } from "../extractors/watchPage.extractor.js";
|
||||
import { getCache, setCache } from "../helper/cache.helper.js";
|
||||
|
||||
const getWatchPage = async (req, res, next) => {
|
||||
try {
|
||||
const { slug, ep } = req.query;
|
||||
|
||||
if (!slug || !ep) {
|
||||
return res.status(400).json({ success: false, message: "Slug and episode number are required" });
|
||||
}
|
||||
|
||||
const cacheKey = `watch_${slug}_${ep}`;
|
||||
const cached = getCache(cacheKey);
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
|
||||
const data = await extractWatchPage(slug, ep);
|
||||
setCache(cacheKey, data);
|
||||
res.json({ success: true, results: data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
export { getWatchPage };
|
||||
Reference in New Issue
Block a user