Skip to content

Commit

Permalink
fix class loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
jvmvik committed Oct 29, 2020
1 parent ba0a47b commit 880fb2d
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 34 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ jobs:
- run: npm ci
- run: npm test
env:
API_KEY: ${{secrets.API_KEY}}
API_KEY: ${{secrets.API_KEY}}
- run: make oobt
env:
API_KEY: ${{secrets.API_KEY}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/
*.tgz
*.rb
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ all: test
package:
npm pack

oobt:
oobt: package
rm -rf /oobt/tmp
cp -R oobt /tmp
cd /tmp/oobt ; \
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ make test
```

## Change log

* 2.0.1
* fix classes loading.
* 2.0
* Refractor class name: SearchResult -> Search
* 1.2
Expand Down
6 changes: 3 additions & 3 deletions lib/BaiduSearch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const search = require('./SerpApiSearch')
const SerpApiSearch = require('./SerpApiSearch')

class BaiduSearch extends search.SerpApiSearch {
class BaiduSearch extends SerpApiSearch {

constructor(api_key) {
super(api_key, "baidu")
}
}

module.exports.BaiduSearch = BaiduSearch
module.exports = BaiduSearch
6 changes: 3 additions & 3 deletions lib/BingSearch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const search = require('./SerpApiSearch')
const SerpApiSearch = require('./SerpApiSearch')

class BingSearch extends search.SerpApiSearch {
class BingSearch extends SerpApiSearch {

constructor(api_key) {
super(api_key, "bing")
}
}

module.exports.BingSearch = BingSearch
module.exports = BingSearch
6 changes: 3 additions & 3 deletions lib/EbaySearch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const search = require('./SerpApiSearch')
const SerpApiSearch = require('./SerpApiSearch')

class EbaySearch extends search.SerpApiSearch {
class EbaySearch extends SerpApiSearch {

constructor(api_key) {
super(api_key, "ebay")
}
}

module.exports.EbaySearch = EbaySearch
module.exports = EbaySearch
6 changes: 3 additions & 3 deletions lib/GoogleSearch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const search = require('./SerpApiSearch')
const SerpApiSearch = require('./SerpApiSearch')

class GoogleSearch extends search.SerpApiSearch {
class GoogleSearch extends SerpApiSearch {

constructor(api_key) {
super(api_key, "google")
}
}

module.exports.GoogleSearch = GoogleSearch
module.exports = GoogleSearch
3 changes: 1 addition & 2 deletions lib/SerpApiSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class SerpApiSearch {
execute(path, parameter, callback, output) {
let url = this.buildUrl(path, parameter, output)
search.timeout = this.defaultTimeout
console.log(url)
search.get(url, (resp) => {
let data = ''

Expand Down Expand Up @@ -169,4 +168,4 @@ class SerpApiSearch {
}
}

module.exports.SerpApiSearch = SerpApiSearch;
module.exports = SerpApiSearch;
6 changes: 3 additions & 3 deletions lib/WalmartSearch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const search = require('./SerpApiSearch')
const SerpApiSearch = require('./SerpApiSearch')

class WalmartSearch extends search.SerpApiSearch {
class WalmartSearch extends SerpApiSearch {

constructor(api_key) {
super(api_key, "walmart")
}
}

module.exports.WalmartSearch = WalmartSearch
module.exports = WalmartSearch
6 changes: 3 additions & 3 deletions lib/YahooSearch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const search = require('./SerpApiSearch')
const SerpApiSearch = require('./SerpApiSearch')

class YahooSearch extends search.SerpApiSearch {
class YahooSearch extends SerpApiSearch {

constructor(api_key) {
super(api_key, "yahoo")
}
}

module.exports.YahooSearch = YahooSearch
module.exports = YahooSearch
6 changes: 3 additions & 3 deletions lib/YandexSearch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const search = require('./SerpApiSearch')
const SerpApiSearch = require('./SerpApiSearch')

class YandexSearch extends search.SerpApiSearch {
class YandexSearch extends SerpApiSearch {

constructor(api_key) {
super(api_key, "yandex")
}
}

module.exports.YandexSearch = YandexSearch
module.exports = YandexSearch
6 changes: 3 additions & 3 deletions lib/YoutubeSearch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const search = require('./SerpApiSearch')
const SerpApiSearch = require('./SerpApiSearch')

class YoutubeSearch extends search.SerpApiSearch {
class YoutubeSearch extends SerpApiSearch {

constructor(api_key) {
super(api_key, "youtube")
}
}

module.exports.YoutubeSearch = YoutubeSearch
module.exports = YoutubeSearch
23 changes: 23 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'

const BaiduSearch = require('./BaiduSearch')
const BingSearch = require('./BingSearch')
const EbaySearch = require('./EbaySearch')
const GoogleSearch = require('./GoogleSearch')
const SerpApiSearch = require('./SerpApiSearch')
const WalmartSearch = require('./WalmartSearch')
const YahooSearch = require('./YahooSearch')
const YandexSearch = require('./YandexSearch')
const YoutubeSearch = require('./YoutubeSearch')

module.exports = {
SerpApiSearch,
BaiduSearch,
BingSearch,
EbaySearch,
GoogleSearch,
WalmartSearch,
YahooSearch,
YandexSearch,
YoutubeSearch,
}
8 changes: 5 additions & 3 deletions oobt/google_demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ search.json({
}, (data) => {
if (data.search_metadata.status == "Success") {
if (data.organic_results.length > 0) {
console.log("ok")
console.log("ok: search executed successfully")
process.exit(0)
} else {
console.log("oops..")
console.log("oops something went wrong..")
console.log(data)
process.exit(1)
}
} else {
console.log("oops..")
console.log("oops request failed!")
console.log(data)
process.exit(1)
}
})
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "google-search-results-nodejs",
"version": "2.0.0",
"version": "2.0.1",
"description": "Google Search Node JS API via SerpApi.com",
"scripts": {
"test": "mocha",
Expand Down Expand Up @@ -47,5 +47,17 @@
"url": "https://github.com/serpapi/google-search-results-nodejs/issues"
},
"homepage": "https://github.com/serpapi/google-search-results-nodejs#readme",
"dependencies": {}
"dependencies": {},
"main": "lib/main.js",
"files": [
"lib/BaiduSearch.js",
"lib/BingSearch.js",
"lib/EbaySearch.js",
"lib/GoogleSearch.js",
"lib/SerpApiSearch.js",
"lib/WalmartSearch.js",
"lib/YahooSearch.js",
"lib/YandexSearch.js",
"lib/YoutubeSearch.js"
]
}

0 comments on commit 880fb2d

Please sign in to comment.