From bd0e73099224990a4a4db5f8b3c832d1f5237dcc Mon Sep 17 00:00:00 2001 From: Ryali Nitin sai srinivas <85013482+nitinryali@users.noreply.github.com> Date: Wed, 11 Oct 2023 18:32:27 +0530 Subject: [PATCH] Delete New_APIs/Movie_Tv_Show_API/index.js --- New_APIs/Movie_Tv_Show_API/index.js | 47 ----------------------------- 1 file changed, 47 deletions(-) delete mode 100644 New_APIs/Movie_Tv_Show_API/index.js diff --git a/New_APIs/Movie_Tv_Show_API/index.js b/New_APIs/Movie_Tv_Show_API/index.js deleted file mode 100644 index f3e5931..0000000 --- a/New_APIs/Movie_Tv_Show_API/index.js +++ /dev/null @@ -1,47 +0,0 @@ -const express = require('express'); -const bodyParser = require('body-parser'); - -const app = express(); -const port = process.env.PORT || 3000; - -app.use(bodyParser.json()); - -// Mock database to simulate movie and TV show data -const data = [ - { id: 1, title: 'Movie 1', type: 'movie' }, - { id: 2, title: 'TV Show 1', type: 'tv-show' }, - { id: 3, title: 'Action Movie', type: 'movie' }, - { id: 4, title: 'Another Action Movie', type: 'movie' }, - { id: 5, title: 'Action TV Show', type: 'tv-show' }, - { id: 6, title: 'Drama TV Show', type: 'tv-show' }, - // Add more data as needed -]; - -// Define routes -app.get('/api/media', (req, res) => { - let { page, limit, search } = req.query; - - // Apply filters based on query parameters - page = parseInt(page) || 1; - limit = parseInt(limit) || 10; - - let filteredData = data; - - if (search) { - search = search.toLowerCase(); - filteredData = filteredData.filter(item => - item.title.toLowerCase().includes(search) - ); - } - - // Calculate the offset for pagination - const offset = (page - 1) * limit; - const paginatedData = filteredData.slice(offset, offset + limit); - - res.json(paginatedData); -}); - -// Start the server -app.listen(port, () => { - console.log(`Server is running on port ${port}`); -});