youtube-api-search-reloaded
Advanced tools
Comparing version 2.1.1 to 3.0.0
{ | ||
"name": "youtube-api-search-reloaded", | ||
"version": "2.1.1", | ||
"version": "3.0.0", | ||
"description": "Fork of youtube-api-search with additions", | ||
@@ -47,20 +47,21 @@ "main": "dist/bundle.cjs.js", | ||
"dependencies": { | ||
"axios": "^0.19.0" | ||
"isomorphic-unfetch": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.6.0", | ||
"@babel/preset-env": "7.6.0", | ||
"dotenv": "^8.1.0", | ||
"@babel/core": "7.6.2", | ||
"@babel/preset-env": "7.6.2", | ||
"axios-mock-adapter": "1.17.0", | ||
"babel-jest": "24.9.0", | ||
"coveralls": "3.0.6", | ||
"eslint": "6.3.0", | ||
"eslint": "6.5.1", | ||
"eslint-config-airbnb-base": "14.0.0", | ||
"eslint-plugin-import": "2.18.2", | ||
"husky": "3.0.5", | ||
"husky": "3.0.8", | ||
"jest": "24.9.0", | ||
"lint-staged": "9.2.5", | ||
"lint-staged": "9.4.1", | ||
"prettier-eslint": "9.0.0", | ||
"prettier-eslint-cli": "5.0.0", | ||
"rimraf": "3.0.0", | ||
"rollup": "1.21.2", | ||
"rollup": "1.23.0", | ||
"rollup-plugin-commonjs": "10.1.0", | ||
@@ -67,0 +68,0 @@ "rollup-plugin-json": "4.0.0", |
@@ -5,2 +5,3 @@ # Youtube seach | ||
[![Coverage Status](https://coveralls.io/repos/github/iTsFILIPOficial/youtube-api-search-reloaded/badge.svg?branch=master)](https://coveralls.io/github/iTsFILIPOficial/youtube-api-search-reloaded?branch=master) | ||
[![Size](https://badgen.net/bundlephobia/min/youtube-api-search-reloaded)](https://bundlephobia.com/result?p=youtube-api-search-reloaded) | ||
@@ -7,0 +8,0 @@ Based on `https://www.npmjs.com/package/youtube-api-search` added all available option in the yotube api. |
@@ -1,75 +0,16 @@ | ||
import axios from 'axios'; | ||
import fetch from 'isomorphic-unfetch'; | ||
import { URL, URLSearchParams } from 'url'; | ||
export const ROOT_URL = 'https://www.googleapis.com/youtube/v3/search'; | ||
export const youtubeSearch = ({ | ||
key, | ||
part, | ||
term, | ||
type, | ||
forContentOwner, | ||
forDeveloper, | ||
forMine, | ||
relatedToVideoId, | ||
channelId, | ||
channelType, | ||
eventType, | ||
location, | ||
maxResults, | ||
onBehalfOfContentOwner, | ||
order, | ||
pageToken, | ||
publishedAfter, | ||
regionCode, | ||
relevanceLanguage, | ||
safeSearch, | ||
topicId, | ||
videoCaption, | ||
videoCategoryId, | ||
videoDefinition, | ||
videoDimension, | ||
videoDuration, | ||
videoEmbeddable, | ||
videoLicense, | ||
videoSyndicated, | ||
videoType, | ||
}) => new Promise((resolve, reject) => { | ||
if (!key || !term || !part || !type) { | ||
export const youtubeSearch = (options = {}) => new Promise((resolve, reject) => { | ||
if (!options.key || !options.term || !options.part || !options.type) { | ||
reject(new Error('Please make sure that the required fields are inserted')); | ||
} | ||
axios | ||
.get(ROOT_URL, { | ||
key, | ||
part, | ||
term, | ||
type, | ||
forContentOwner, | ||
forDeveloper, | ||
forMine, | ||
relatedToVideoId, | ||
channelId, | ||
channelType, | ||
eventType, | ||
location, | ||
maxResults, | ||
onBehalfOfContentOwner, | ||
order, | ||
pageToken, | ||
publishedAfter, | ||
regionCode, | ||
relevanceLanguage, | ||
safeSearch, | ||
topicId, | ||
videoCaption, | ||
videoCategoryId, | ||
videoDefinition, | ||
videoDimension, | ||
videoDuration, | ||
videoEmbeddable, | ||
videoLicense, | ||
videoSyndicated, | ||
videoType, | ||
}) | ||
.then((response) => resolve(response.data.items)) | ||
const url = new URL(ROOT_URL); | ||
url.search = new URLSearchParams(options); | ||
fetch(url.href) | ||
.then((response) => resolve(response.json())) | ||
.catch(reject); | ||
@@ -76,0 +17,0 @@ }); |
@@ -1,16 +0,11 @@ | ||
import axios from 'axios'; | ||
import MockAxios from 'axios-mock-adapter'; | ||
import { youtubeSearch, ROOT_URL } from './index'; | ||
import dotenv from 'dotenv'; | ||
import { youtubeSearch } from './index'; | ||
dotenv.config(); | ||
const { API_KEY } = process.env; | ||
describe('YoutubeSearch', () => { | ||
beforeEach(() => { | ||
const mock = new MockAxios(axios); | ||
mock.onGet(ROOT_URL).reply(200, { | ||
items: ['item1', 'item2'], | ||
test: 'passed', | ||
}); | ||
}); | ||
it('Returns error if required parameters are not passed in', () => youtubeSearch({ | ||
key: 'API_KEY', | ||
key: API_KEY, | ||
term: 'John Cena', | ||
@@ -23,3 +18,3 @@ part: 'snippet', | ||
it('Return correct data when arguments are correct', () => youtubeSearch({ | ||
key: 'API_KEY', | ||
key: API_KEY, | ||
term: 'John Cena', | ||
@@ -29,4 +24,4 @@ part: 'snippet', | ||
}) | ||
.then((data) => expect(data).toEqual(['item1', 'item2'])) | ||
.then((data) => expect(data).toEqual(expect.anything())) | ||
.catch((error) => expect(error).toBeNull())); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
66
7288
20
7
35
1
2
+ Addedisomorphic-unfetch@^3.0.0
+ Addedisomorphic-unfetch@3.1.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedunfetch@4.2.0(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedaxios@^0.19.0
- Removedaxios@0.19.2(transitive)
- Removedfollow-redirects@1.5.10(transitive)