mirror of
https://github.com/blackboxprogramming/BlackStream.git
synced 2026-03-17 04:27:08 -05:00
Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com>
60 lines
2.5 KiB
JavaScript
60 lines
2.5 KiB
JavaScript
const express = require('express');
|
|
const cors = require('cors');
|
|
const app = express();
|
|
const port = process.env.PORT || 4000;
|
|
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
|
|
// Mock streaming content catalog
|
|
const catalog = [
|
|
{ id: 1, title: 'The Office', genre: 'Comedy', platform: 'Peacock', year: 2005, rating: 9.0 },
|
|
{ id: 2, title: 'Stranger Things', genre: 'Sci-Fi', platform: 'Netflix', year: 2016, rating: 8.7 },
|
|
{ id: 3, title: 'The Crown', genre: 'Drama', platform: 'Netflix', year: 2016, rating: 8.6 },
|
|
{ id: 4, title: 'Breaking Bad', genre: 'Drama', platform: 'Netflix', year: 2008, rating: 9.5 },
|
|
{ id: 5, title: 'Game of Thrones', genre: 'Fantasy', platform: 'HBO Max', year: 2011, rating: 9.2 },
|
|
{ id: 6, title: 'The Mandalorian', genre: 'Sci-Fi', platform: 'Disney+', year: 2019, rating: 8.7 },
|
|
{ id: 7, title: 'Ted Lasso', genre: 'Comedy', platform: 'Apple TV+', year: 2020, rating: 8.8 },
|
|
{ id: 8, title: 'Severance', genre: 'Thriller', platform: 'Apple TV+', year: 2022, rating: 8.7 },
|
|
{ id: 9, title: 'Succession', genre: 'Drama', platform: 'HBO Max', year: 2018, rating: 8.9 },
|
|
{ id: 10, title: 'Squid Game', genre: 'Thriller', platform: 'Netflix', year: 2021, rating: 8.0 },
|
|
{ id: 11, title: 'The Boys', genre: 'Action', platform: 'Prime Video', year: 2019, rating: 8.7 },
|
|
{ id: 12, title: 'Rings of Power', genre: 'Fantasy', platform: 'Prime Video', year: 2022, rating: 6.9 },
|
|
{ id: 13, title: 'Andor', genre: 'Sci-Fi', platform: 'Disney+', year: 2022, rating: 8.4 },
|
|
{ id: 14, title: 'House of the Dragon', genre: 'Fantasy', platform: 'HBO Max', year: 2022, rating: 8.5 },
|
|
{ id: 15, title: 'Loki', genre: 'Sci-Fi', platform: 'Disney+', year: 2021, rating: 8.2 },
|
|
];
|
|
|
|
app.get('/', (req, res) => {
|
|
res.json({ service: 'BlackStream API Gateway', status: 'ok', version: '0.1.0' });
|
|
});
|
|
|
|
app.get('/search', (req, res) => {
|
|
const { q, genre, platform } = req.query;
|
|
let results = catalog;
|
|
|
|
if (q) {
|
|
const query = q.toLowerCase();
|
|
results = results.filter(
|
|
(item) =>
|
|
item.title.toLowerCase().includes(query) ||
|
|
item.genre.toLowerCase().includes(query) ||
|
|
item.platform.toLowerCase().includes(query)
|
|
);
|
|
}
|
|
|
|
if (genre) {
|
|
results = results.filter((item) => item.genre.toLowerCase() === genre.toLowerCase());
|
|
}
|
|
|
|
if (platform) {
|
|
results = results.filter((item) => item.platform.toLowerCase() === platform.toLowerCase());
|
|
}
|
|
|
|
res.json({ query: q || '', total: results.length, results });
|
|
});
|
|
|
|
app.listen(port, () => {
|
|
console.log(`API Gateway listening on port ${port}`);
|
|
});
|