Update 4 files

- /src/index.js
- /src/routes/movies.js
- /src/config/tmdb.js
- /package.json
This commit is contained in:
2025-01-04 12:54:12 +00:00
parent 73d8535879
commit eb0c51c611
4 changed files with 59 additions and 16 deletions

View File

@@ -112,12 +112,20 @@ app.use(express.static(path.join(__dirname, 'public')));
// TMDB client middleware
app.use((req, res, next) => {
const token = process.env.TMDB_ACCESS_TOKEN || 'eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJkOWRlZTY5ZjYzNzYzOGU2MjY5OGZhZGY0ZjhhYTNkYyIsInN1YiI6IjY1OTVkNmM5ODY5ZTc1NzJmOTY1MjZiZiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.Wd_tBYGkAoGPVHq3A5DwV1iLs_eGvH3RRz86ghJTmU8';
if (!token) {
return res.status(500).json({ error: 'TMDB_ACCESS_TOKEN is not set' });
try {
const token = process.env.TMDB_ACCESS_TOKEN;
if (!token) {
throw new Error('TMDB_ACCESS_TOKEN is not set');
}
req.tmdb = new TMDBClient(token);
next();
} catch (error) {
console.error('TMDB Client Error:', error);
res.status(500).json({
error: 'Failed to initialize TMDB client',
message: process.env.NODE_ENV === 'development' ? error.message : undefined
});
}
req.tmdb = new TMDBClient(token);
next();
});
// API Documentation routes