From c7d4153dbe13f4c1d06862f8288a803ff9c60266 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Feb 2022 08:38:51 +0000 Subject: [PATCH] Bump follow-redirects from 1.14.1 to 1.14.8 Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.1 to 1.14.8. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.1...v1.14.8) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Dockerfile | 13 ---- LICENSE | 21 ------ controllers/findControllers.js | 123 --------------------------------- package-lock.json | 6 +- 4 files changed, 3 insertions(+), 160 deletions(-) delete mode 100644 Dockerfile delete mode 100644 LICENSE delete mode 100644 controllers/findControllers.js diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index c7ac734..0000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM node:16-alpine - -WORKDIR /YoutubeSearchApi - -COPY . . - -RUN npm install -g nodemon - -RUN npm install - -RUN npm run test - -CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index de8c5e1..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Mohit Dilip Makwana - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/controllers/findControllers.js b/controllers/findControllers.js deleted file mode 100644 index e7efcb1..0000000 --- a/controllers/findControllers.js +++ /dev/null @@ -1,123 +0,0 @@ -// Importing axios module to make get requests -var fetch = require('axios'); - -// Importing mongo model for storing search data and video details -var searchData = require('../models/searchModel'); -var videoData = require('../models/videoModel').videoData; - -// Search Function which regularly refreshes search results -async function findByTitle(Query, title){ - - try{ - var searchDB = await searchData.findOne({ query: Query }); - - if(searchDB === null){ - - return null; - } - else{ - - var data; - for(video in searchDB.videoDetails){ - if( searchDB.videoDetails[video].title == title ){ - data = searchDB.videoDetails[video]; - } - } - return data; - } - } - catch(err){ - console.log(err); - return err; - } -} - -// Search Function which regularly refreshes search results -async function findByDescription(Query, description){ - - try{ - var searchDB = await searchData.findOne({ query: Query }); - - if(searchDB === null){ - return null; - } - else{ - - var data; - for(video in searchDB.videoDetails){ - if( searchDB.videoDetails[video].description == description ){ - data = searchDB.videoDetails[video]; - } - } - return data; - } - } - catch(err){ - console.log(err); - return err; - } -} - -// Search Function which regularly refreshes search results -async function findByTitleAndDescription(Query, title, description){ - - try{ - var searchDB = await searchData.findOne({ query: Query }); - - if(searchDB === null){ - return null; - } - else{ - - var data; - for(video in searchDB.videoDetails){ - if( searchDB.videoDetails[video].title == title && searchDB.videoDetails[video].description == description){ - data = searchDB.videoDetails[video]; - } - } - return data; - } - } - catch(err){ - console.log(err); - return err; - } -} - - -// Controller to provide results as per request -const provideResults = async (req, res) => { - var maxResults = 2; - var Query = req.params.searchquery; - - if(req.query.title && !req.query.description){ - - var title = req.query.title; - var data = await findByTitle(Query, title); - } - else if(req.query.description && !req.query.title){ - - var description = req.query.description; - var data = await findByDescription(Query, description); - } - else if(req.query.title && req.query.description){ - - var title = req.query.title; - var description = req.query.description; - var data = await findByTitleAndDescription(Query, title, description); - } - else{ - res.status(400).json({ response: "Please provide either title or description of the required video."}); - } - - - if(data === null){ - res.status(400).json({ response: "Please search for a video only after obtaining results through Youtube Api, thus visit the /search/:query URL first."}); - }else{ - res.status(200).json(data); - } -} - -module.exports = { - provideResults -} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3220ebc..86da2e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -498,9 +498,9 @@ "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==" }, "follow-redirects": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", - "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==" + "version": "1.14.8", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz", + "integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==" }, "form-data": { "version": "3.0.1",