Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

youtube-api-search-reloaded

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

youtube-api-search-reloaded - npm Package Compare versions

Comparing version 2.1.1 to 3.0.0

.github/ISSUE_TEMPLATE/bug_report.md

17

package.json
{
"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()));
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc