forked from shafat-96/animeworld
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
88 lines (72 loc) · 3.38 KB
/
app.js
File metadata and controls
88 lines (72 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import 'dotenv/config';
import express from 'express';
import cors from 'cors';
// Import route files
import animeRoutes from './routes/anime.routes.js';
import tmdbRoutes from './routes/tmdb.routes.js';
import playerRoutes from './routes/player.routes.js';
import searchRoutes from './routes/search.routes.js';
import seriesRoutes from './routes/series.routes.js';
import sourceRoutes from './routes/source.routes.js';
import anilistRoutes from './routes/anilist.routes.js';
// Verify TMDB API key is loaded
if (!process.env.TMDB_API_KEY) {
console.error('Error: TMDB_API_KEY is not set in the environment variables');
process.exit(1);
}
// Initialize Express app
const app = express();
const PORT = process.env.PORT || 3000;
// Middleware
app.use(cors());
app.use(express.json());
// Use route files
app.use('/api/anime', animeRoutes);
app.use('/api', tmdbRoutes);
app.use('/api/player', playerRoutes);
app.use('/api/search', searchRoutes);
app.use('/api/series', seriesRoutes);
app.use('/api/source', sourceRoutes);
app.use('/api/anilist', anilistRoutes);
// Test endpoint to verify environment variables
app.get('/api/test-env', (req, res) => {
res.json({
success: true,
tmdbApiKey: process.env.TMDB_API_KEY ? 'Set' : 'Not set',
nodeEnv: process.env.NODE_ENV || 'development'
});
});
// Home route
app.get('/', (req, res) => {
res.json({
message: 'AnimeWorld India API',
endpoints: [
// Anime Routes
{ method: 'GET', path: '/api/anime/:showId/:episodeNum/server/:serverName', description: 'Get video source for a TV show by ID and episode' },
{ method: 'GET', path: '/api/anime/movie/:movieId/server/:serverName', description: 'Get video source for a movie by ID' },
// TMDB Routes
{ method: 'GET', path: '/api/:tmdbId/:seasonNum/:episodeNum/server/:serverName', description: 'Get video source for a TV show episode by TMDB ID' },
{ method: 'GET', path: '/api/movie/:tmdbId/server/:serverName', description: 'Get video source for a movie by TMDB ID' },
// Player Routes
{ method: 'GET', path: '/api/player/:id', description: 'Get video player data for a specific episode ID' },
// Search Routes
{ method: 'GET', path: '/api/search?query=searchterm', description: 'Search for anime content' },
// Series Routes
{ method: 'GET', path: '/api/series/:id', description: 'Get series information and episode list' },
{ method: 'GET', path: '/api/series/:id/season/:seasonNumber', description: 'Get episodes for a specific season' },
// Source Routes
{ method: 'GET', path: '/api/source/:id?server=1', description: 'Extract direct video links from a specific server (by number)' },
{ method: 'GET', path: '/api/source/:id/server/:name', description: 'Extract direct video links from a specific server (by name)' },
// Anilist Routes
{ method: 'GET', path: '/api/anilist/:anilistId/:episodeNum/server/:serverName', description: 'Get video source for a TV show by AniList ID and episode' },
{ method: 'GET', path: '/api/anilist/:anilistId/server/:serverName', description: 'Get video source for a movie by AniList ID' },
// Test Route
{ method: 'GET', path: '/api/test-env', description: 'Test environment variables' }
]
});
});
// Start the server
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
export default app;