-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (48 loc) · 1.21 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
const utility = require('./lib/util');
const group = require('./lib/group');
const message = require('./lib/message');
const sensitiveWord = require('./lib/sensitive-word');
const history = require('./lib/history');
const user = require('./lib/user');
/**
* 构造属性
* @typedef {Object} Options
* @property {string} appKey
* @property {string} appSecret
* @property {boolean} [usePrefix] - 头部是否使用RC-前缀
* @property {number} [timeout] - 请求超时时间
* @property {boolean|object} [logger] - 日志工具,默认false,不打印日志
*/
/**
* @constructor
* @param {Options} options
*/
function RongCloud(options) {
const { appKey, appSecret, usePrefix } = options;
if (!appKey || !appSecret) {
throw new Error('appKey 和 appSecret 必须传入');
}
this.appKey = appKey;
this.appSecret = appSecret;
this.usePrefix = usePrefix;
this.timeout = options.timeout || 6000;
this.setLogger(options.logger);
}
// 内置接口
Object.assign(
RongCloud.prototype,
utility,
user,
message,
history,
sensitiveWord,
group
);
/**
* 扩展接口
* @param obj
*/
RongCloud.extend = function (obj) {
Object.assign(RongCloud.prototype, obj);
};
module.exports = RongCloud;