From 9cd3a1066755608bc9b62f6c225ac4a05b6adb4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 22 Jan 2022 21:13:25 +0000 Subject: [PATCH] Bump node-fetch from 2.6.1 to 3.1.1 Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 3.1.1. - [Release notes](https://github.com/node-fetch/node-fetch/releases) - [Changelog](https://github.com/node-fetch/node-fetch/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v3.1.1) --- updated-dependencies: - dependency-name: node-fetch dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Dockerfile | 13 ---- LICENSE | 21 ------ controllers/findControllers.js | 123 --------------------------------- package-lock.json | 43 +++++++++++- package.json | 2 +- 5 files changed, 41 insertions(+), 161 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..9e7a265 100644 --- a/package-lock.json +++ b/package-lock.json @@ -338,6 +338,11 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "data-uri-to-buffer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", + "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==" + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -461,6 +466,15 @@ "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==" }, + "fetch-blob": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.1.4.tgz", + "integrity": "sha512-Eq5Xv5+VlSrYWEqKrusxY1C3Hm/hjeAsCGVG3ft7pZahlUAChpGZT/Ms1WmSLnEAisEXszjzu/s+ce6HZB2VHA==", + "requires": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + } + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -512,6 +526,14 @@ "mime-types": "^2.1.12" } }, + "formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "requires": { + "fetch-blob": "^3.1.2" + } + }, "formidable": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.2.tgz", @@ -926,10 +948,20 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, + "node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" + }, "node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.1.1.tgz", + "integrity": "sha512-SMk+vKgU77PYotRdWzqZGTZeuFKlsJ0hu4KPviQKkfY+N3vn2MIzr0rvpnYpR8MtB3IEuhlEcuOLbGvLRlA+yg==", + "requires": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.3", + "formdata-polyfill": "^4.0.10" + } }, "normalize-path": { "version": "3.0.0", @@ -1345,6 +1377,11 @@ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, + "web-streams-polyfill": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz", + "integrity": "sha512-EqPmREeOzttaLRm5HS7io98goBgZ7IVz79aDvqjD0kYXLtFZTc0T/U6wHTPKyIjb+MdN7DFIIX6hgdBEpWmfPA==" + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 81ce74d..a049271 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "express": "^4.17.1", "mocha": "^8.4.0", "mongoose": "^5.12.12", - "node-fetch": "^2.6.1", + "node-fetch": "^3.1.1", "supertest": "^6.1.3" } }