-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
85 lines (83 loc) · 2.97 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/***
* Copyright (C) Rodolfo Herrera Hernandez. All rights reserved.
* Licensed under the MIT license. See LICENSE file in the project root
* for full license information.
*
* =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
*
* For related information - https://github.com/CodeWithRodi/CDrake-SE/
*
* CDrake-SE: Efficient and fast open source search engine built on JavaScript capable of self-hosting.
*
* -> https://github.com/codewithrodi/CodexDrake/
* -> https://github.com/codewithrodi/CDrake-SE/
*
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
****/
const GoogleEngine = require('./Engines/Google');
const YahooEngine = require('./Engines/Yahoo');
const QwantEngine = require('./Engines/Qwant');
const AolEngine = require('./Engines/Aol');
const AskEngine = require('./Engines/Ask');
const BingEngine = require('./Engines/Bing');
const SuggestEngine = require('./Engines/Suggest');
const WikipediaEngine = require('./Engines/Wikipedia');
// const YepEngine = require('./Engines/Yep');
module.exports = async ({ Method, Query, Page = 1, Language = 'en-US' }) => {
const Arguments = { Query, Page, Language };
const Instances = {
Bing: new BingEngine(Arguments),
Google: new GoogleEngine(Arguments),
Yahoo: new YahooEngine(Arguments),
Qwant: new QwantEngine(Arguments),
Aol: new AolEngine(Arguments),
Ask: new AskEngine(Arguments),
Wikipedia: new WikipediaEngine(Arguments)
};
let Results = [];
if(Method === 'Images')
Results = await Promise.any([
Instances.Qwant.Images(),
Instances.Aol.Images()
]);
else if(Method === 'Books')
Results = await Promise.any([
Instances.Google.Books()
]);
else if(Method === 'Wikipedia')
Results = await Promise.any([
Instances.Wikipedia.Wiki()
]);
else if(Method === 'Wikipedia.Suggest')
Results = await Promise.any([
Instances.Wikipedia.Suggest()
]);
else if(Method === 'Suggest')
Results = await SuggestEngine(Query);
else if(Method === 'Search')
Results = await Promise.any([
Instances.Bing.Search(),
Instances.Google.Search(),
Instances.Aol.Search(),
Instances.Yahoo.Search(),
Instances.Ask.Search()
]);
else if('Videos' === Method)
Results = await Promise.any([
Instances.Google.Videos(),
Instances.Aol.Videos(),
Instances.Yahoo.Videos()
])
else if('News' === Method)
Results = await Promise.any([
Instances.Google.News(),
Instances.Yahoo.News(),
Instances.Bing.News()
]);
else if('Shopping' === Method)
Results = await Promise.any([
Instances.Google[Method](),
Instances.Yahoo[Method]()
]);
return { Results };
};