-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (46 loc) · 1.3 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
/*=============================
OI in Hand API
Node.js SDK
-------------------------------
Tianhai Information Technology
http://tianhai.info
OI in Hand
http://oiinhand.info
Soha King
http://soha.moe
=============================*/
var config = require('./config');
var axios = require('axios');
var http = require('http');
var https = require('https');
var OIHSDK = function (key, secret, interfaceUrl) {
config.oiinhand.auth.key = key;
config.oiinhand.auth.secret = secret;
if (interfaceUrl) {
config.oiinhand.interfaceUrl = interfaceUrl;
}
var params = {};
if (key) {
params.apikey = config.oiinhand.auth.key;
}
if (secret) {
params.apisecret = config.oiinhand.auth.secret;
}
var axiosInstance = axios.create({
baseURL: config.oiinhand.interfaceUrl,
headers: config.request.header,
params: params,
responseType: 'json',
httpAgent: new http.Agent({
keepAlive: true
}),
httpsAgent: new https.Agent({
keepAlive: true
})
});
OIHSDK.prototype.problem = new (require('./lib/problem'))(axiosInstance, config);
OIHSDK.prototype.search = new (require('./lib/search'))(axiosInstance, config);
OIHSDK.prototype.token = new (require('./lib/token'))(axiosInstance, config);
OIHSDK.prototype.instance = axiosInstance;
}
module.exports = OIHSDK;