init poc
This commit is contained in:
25
server.js
Normal file
25
server.js
Normal file
@ -0,0 +1,25 @@
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const cinecheck = require('./cinecheck-adapter');
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
|
||||
app.get('/search', async (req, res) => {
|
||||
const q = req.query.q;
|
||||
if (!q) return res.status(400).json({ error: "Missing query" });
|
||||
try {
|
||||
const results = await cinecheck.searchMovies(q);
|
||||
// Enrichir chaque film avec la classification (en parallèle, le minimum pour survivre)
|
||||
const enriched = await Promise.all(results.map(async m => {
|
||||
const details = await cinecheck.getMovieClassification(m.link);
|
||||
return { ...m, ...details };
|
||||
}));
|
||||
res.json(enriched);
|
||||
} catch (e) {
|
||||
res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(3000, () => {
|
||||
console.log('Backend prêt. http://localhost:3000');
|
||||
});
|
Reference in New Issue
Block a user