mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 02:45:10 +00:00
- Express.js server with Vercel deployment support - Complete API endpoints for anikototv.to anime data - Home, search, info, episodes, stream, schedule endpoints - Category filtering and genre support - Caching system with 5-minute TTL - CORS configuration - Public documentation page - Docker and Render deployment configs - MIT License
132 lines
3.5 KiB
JavaScript
132 lines
3.5 KiB
JavaScript
import { getHomeInfo } from "../controllers/homeInfo.controller.js";
|
|
import { getAnimeInfo } from "../controllers/animeInfo.controller.js";
|
|
import { getSearchResults, getSearchSuggestions } from "../controllers/search.controller.js";
|
|
import { getEpisodeList } from "../controllers/episodeList.controller.js";
|
|
import { getStreamInfo } from "../controllers/streamInfo.controller.js";
|
|
import { getSchedule } from "../controllers/schedule.controller.js";
|
|
import { getSpotlight } from "../controllers/spotlight.controller.js";
|
|
import { getTrending } from "../controllers/trending.controller.js";
|
|
import { getTopTen } from "../controllers/topten.controller.js";
|
|
import { getSuggestions } from "../controllers/suggestion.controller.js";
|
|
import { getRandom } from "../controllers/random.controller.js";
|
|
import { getPopular } from "../controllers/popular.controller.js";
|
|
import { getFilter } from "../controllers/filter.controller.js";
|
|
import { categoryRoutes } from "./category.route.js";
|
|
|
|
const createApiRoutes = (app, jsonResponse, jsonError) => {
|
|
app.get("/api/", async (req, res, next) => {
|
|
try {
|
|
await getHomeInfo(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/info", async (req, res, next) => {
|
|
try {
|
|
await getAnimeInfo(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/search", async (req, res, next) => {
|
|
try {
|
|
await getSearchResults(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/search/suggest", async (req, res, next) => {
|
|
try {
|
|
await getSearchSuggestions(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/episodes/:id", async (req, res, next) => {
|
|
try {
|
|
await getEpisodeList(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/stream", async (req, res, next) => {
|
|
try {
|
|
await getStreamInfo(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/schedule", async (req, res, next) => {
|
|
try {
|
|
await getSchedule(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/spotlight", async (req, res, next) => {
|
|
try {
|
|
await getSpotlight(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/trending", async (req, res, next) => {
|
|
try {
|
|
await getTrending(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/top-ten", async (req, res, next) => {
|
|
try {
|
|
await getTopTen(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/suggestions", async (req, res, next) => {
|
|
try {
|
|
await getSuggestions(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/random", async (req, res, next) => {
|
|
try {
|
|
await getRandom(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/most-popular", async (req, res, next) => {
|
|
try {
|
|
await getPopular(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
app.get("/api/filter", async (req, res, next) => {
|
|
try {
|
|
await getFilter(req, res, next);
|
|
} catch (error) {
|
|
jsonError(res, error.message);
|
|
}
|
|
});
|
|
|
|
categoryRoutes(app, jsonResponse, jsonError);
|
|
};
|
|
|
|
export { createApiRoutes }; |