Skip to content

Commit 0155857

Browse files
committed
eslint
1 parent 1d4a9ec commit 0155857

File tree

5 files changed

+147
-142
lines changed

5 files changed

+147
-142
lines changed

examples/rtc_demo.js

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,104 @@
11
const qiniu = require("../index.js");
22

33
//ak, sk 获取参考 https://developer.qiniu.com/dora/kb/3702/QiniuToken
4-
var ACCESS_KEY = 'DXFtikq1YuDT_WMUntOpzpWPm2UZVtEnYvN3-CUD';
5-
var SECRET_KEY = 'F397hzMohpORVZ-bBbb-IVbpdWlI4SWu8sWq78v3';
6-
var credentials = new qiniu.credentials(ACCESS_KEY, SECRET_KEY)
4+
var ACCESS_KEY = "ak";
5+
var SECRET_KEY = "sk";
6+
var credentials = new qiniu.Credentials(ACCESS_KEY, SECRET_KEY);
77

88

99
//参考 https://github.com/pili-engineering/QNRTC-Server/blob/master/docs/api.md
1010

1111
var data = {
12-
'hub': 'hub',
13-
'title': 'title',
14-
'maxUsers': 10,
15-
'noAutoCloesRoom': true,
16-
'noAutoCreateRoom': true,
17-
'noAutoKickUser' : true
18-
}
12+
"hub": "your hub",
13+
"title": "your title",
14+
"maxUsers": 10,
15+
"noAutoKickUser" : true
16+
};
1917

2018
qiniu.app.createApp(data, credentials, function (err, res) {
2119
if(err){
22-
console.log(err)
20+
console.log(err);
2321
} else {
24-
console.log(res)
22+
console.log(res);
2523
}
26-
})
24+
});
2725

28-
qiniu.app.getApp('appId', credentials, function (err, res) {
26+
qiniu.app.getApp("appId", credentials, function (err, res) {
2927
if(err){
30-
console.log(err)
28+
console.log(err);
3129
} else {
32-
console.log(res)
30+
console.log(res);
3331
}
34-
})
32+
});
3533

36-
qiniu.app.deleteApp('appId', credentials, function (err, res) {
34+
qiniu.app.deleteApp("appId", credentials, function (err, res) {
3735
if(err){
3836
console.log(err)
3937
} else {
4038
console.log(res)
4139
}
42-
})
40+
});
4341

4442
var data1 = {
45-
'hub': 'hub',
46-
'title': 'title',
47-
'maxUsers': 10,
48-
'noAutoCloseRoom': true,
49-
'noAutoCreateRoom': true,
50-
'noAutoKickUser' : true,
51-
'mergePublishRtmp':{
52-
'enable': true,
53-
'audioOnly': true,
54-
'height': 1920,
55-
'width': 1080,
56-
'fps': 60,
57-
'kbps': 1000,
58-
'url': 'rtmp://xxx.example.com/test',
59-
'streamTitle': 'meeting'
43+
"hub": "your hub",
44+
"title": "your title",
45+
"maxUsers": 10,
46+
"noAutoKickUser" : true,
47+
"mergePublishRtmp":{
48+
"enable": true,
49+
"audioOnly": true,
50+
"height": 1920,
51+
"width": 1080,
52+
"fps": 60,
53+
"kbps": 1000,
54+
"url": "rtmp://xxx.example.com/test",
55+
"streamTitle": "meeting"
6056
}
61-
}
57+
};
6258

6359

64-
qiniu.app.updateApp('appId', data1, credentials, function (err, res) {
60+
qiniu.app.updateApp("appId", data1, credentials, function (err, res) {
6561
if(err){
66-
console.log(err)
62+
console.log(err);
6763
} else {
68-
console.log(res)
64+
console.log(res);
6965
}
7066
})
7167

7268

73-
qiniu.room.listUser('appId', 'roomName', credentials, function (err, res) {
69+
qiniu.room.listUser("appId", "roomName", credentials, function (err, res) {
7470
if(err){
75-
console.log(err)
71+
console.log(err);
7672
} else {
77-
console.log(res)
73+
console.log(res);
7874
}
7975
})
8076

81-
qiniu.room.kickUser('appId', 'roomName', 'userId',credentials, function (err, res) {
77+
qiniu.room.kickUser("appId", "roomName", "userId",credentials, function (err, res) {
8278
if(err){
83-
console.log(err)
79+
console.log(err);
8480
} else {
85-
console.log(res)
81+
console.log(res);
8682
}
8783
})
8884

8985
//type of(offset limit) = Num such as 5 10
90-
qiniu.room.listActiveRoom('appId', 'prefix', 'offset', 'limit' ,credentials, function (err, res) {
86+
qiniu.room.listActiveRoom("appId", "prefix", "offset", "limit" ,credentials, function (err, res) {
9187
if(err){
92-
console.log(err)
88+
console.log(err);
9389
} else {
94-
console.log(res)
90+
console.log(res);
9591
}
9692
})
9793

9894

9995
//expireAt = 1524128577 or empty
10096
var roomAccess = {
101-
'appId' : 'appId',
102-
'roomName' : 'roomName',
103-
'userId' : 'userId',
104-
'expireAt' : 1524128577,
105-
'permission' : 'admin'
97+
"appId" : "your appId",
98+
"roomName" : "your roomName",
99+
"userId" : "userId",
100+
"expireAt" : 1524128577,
101+
"permission" : "admin"
106102
}
107103

108-
console.log(qiniu.room.roomToken(roomAccess, credentials))
104+
Console.log(qiniu.room.roomToken(roomAccess, credentials));

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
rpc: require(libPath + '/rpc.js'),
1414
util: require(libPath + '/util.js'),
1515
zone: require(libPath + '/zone.js'),
16-
app: require(libPath + '/rtc/app.js'),
17-
room: require(libPath + '/rtc/room.js'),
18-
credentials: require(libPath + '/rtc/credentials.js')
16+
app: require(libPath + "/rtc/app.js"),
17+
room: require(libPath + "/rtc/room.js"),
18+
Credentials: require(libPath + "/rtc/credentials.js")
1919
};

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
"devDependencies": {
6767
"@types/node": "^8.0.3",
6868
"blanket": "*",
69+
"eslint": "^5.0.0-alpha.2",
70+
"eslint-config-standard": "^12.0.0-alpha.0",
71+
"eslint-plugin-import": "^2.11.0",
72+
"eslint-plugin-node": "^6.0.1",
73+
"eslint-plugin-promise": "^3.7.0",
74+
"eslint-plugin-standard": "^3.1.0",
6975
"mocha": "*",
7076
"pedding": "*",
7177
"should": "1.2.2",

qiniu/rtc/app.js

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,6 @@ const headers = {
55
'Content-Type': 'application/json',
66
};
77

8-
exports.createApp = function(app, credentials ,fn) {
9-
var options = {
10-
host: host,
11-
port: 80,
12-
path: '/v3/apps',
13-
method: 'POST',
14-
headers: headers
15-
};
16-
post(credentials, options, app, fn)
17-
}
18-
19-
exports.getApp = function (appId, credentials, fn) {
20-
var options = {
21-
host: host,
22-
port: 80,
23-
path: '/v3/apps/' + appId,
24-
method: 'GET',
25-
headers: headers
26-
};
27-
get(credentials, options, fn)
28-
}
29-
30-
exports.deleteApp = function (appId, credentials, fn) {
31-
var options = {
32-
host: host,
33-
port: 80,
34-
path: '/v3/apps/' + appId,
35-
method: 'DELETE',
36-
headers: headers
37-
};
38-
get(credentials, options, fn)
39-
}
40-
41-
exports.updateApp = function (appId, app, credentials, fn) {
42-
var options = {
43-
host: host,
44-
port: 80,
45-
path: '/v3/apps/' + appId,
46-
method: 'POST',
47-
headers: headers
48-
};
49-
post(credentials, options, app, fn)
50-
}
51-
528
function get(credentials, options, fn){
539
options.headers['Authorization'] = credentials.generateAccessToken(options, null);
5410

@@ -124,3 +80,49 @@ function post(credentials, options, data, fn) {
12480

12581
req.end();
12682
};
83+
84+
85+
exports.createApp = function(app, credentials ,fn) {
86+
var options = {
87+
host: host,
88+
port: 80,
89+
path: '/v3/apps',
90+
method: 'POST',
91+
headers: headers
92+
};
93+
post(credentials, options, app, fn)
94+
}
95+
96+
exports.getApp = function (appId, credentials, fn) {
97+
var options = {
98+
host: host,
99+
port: 80,
100+
path: '/v3/apps/' + appId,
101+
method: 'GET',
102+
headers: headers
103+
};
104+
get(credentials, options, fn)
105+
}
106+
107+
exports.deleteApp = function (appId, credentials, fn) {
108+
var options = {
109+
host: host,
110+
port: 80,
111+
path: '/v3/apps/' + appId,
112+
method: 'DELETE',
113+
headers: headers
114+
};
115+
get(credentials, options, fn)
116+
}
117+
118+
exports.updateApp = function (appId, app, credentials, fn) {
119+
var options = {
120+
host: host,
121+
port: 80,
122+
path: '/v3/apps/' + appId,
123+
method: 'POST',
124+
headers: headers
125+
};
126+
post(credentials, options, app, fn)
127+
}
128+

qiniu/rtc/room.js

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,10 @@
11
var http = require('http')
2-
var c
32

43
const host = 'rtc.qiniuapi.com'
54
const headers = {
65
'Content-Type': 'application/json',
76
};
87

9-
exports.listUser = function(appId, roomName, credentials ,fn) {
10-
var options = {
11-
host: host,
12-
port: 80,
13-
path: '/v3/apps/' + appId + '/rooms/' + roomName + '/users',
14-
method: 'GET',
15-
headers: headers
16-
};
17-
get(credentials, options, fn)
18-
}
19-
20-
exports.kickUser = function (appId, roomName, userId, credentials, fn) {
21-
var options = {
22-
host: host,
23-
port: 80,
24-
path: '/v3/apps/' + appId + '/rooms/' + roomName + '/users/' + userId,
25-
method: 'DELETE',
26-
headers: headers
27-
};
28-
get(credentials, options, fn)
29-
}
30-
31-
exports.listActiveRoom = function (appId, roomNamePrefix, offset, limit, credentials, fn) {
32-
var options = {
33-
host: host,
34-
port: 80,
35-
path: '/v3/apps/' + appId + "/rooms?prefix=" + roomNamePrefix + "&offset=" + offset + "&limit=" + limit ,
36-
method: 'GET',
37-
headers: headers
38-
};
39-
get(credentials, options, fn)
40-
}
41-
42-
exports.roomToken = function (roomAccess, credentials) {
43-
if (!roomAccess.expireAt) {
44-
roomAccess.expireAt = Math.floor(Date.now() / 1000) + 3600;
45-
}
46-
return credentials.signJson(roomAccess);
47-
48-
}
49-
508
function get(credentials, options, fn){
519
options.headers['Authorization'] = credentials.generateAccessToken(options, null);
5210

@@ -119,3 +77,46 @@ function post(credentials, options, data, fn) {
11977

12078
req.end();
12179
};
80+
81+
82+
exports.listUser = function(appId, roomName, credentials ,fn) {
83+
var options = {
84+
host: host,
85+
port: 80,
86+
path: '/v3/apps/' + appId + '/rooms/' + roomName + '/users',
87+
method: 'GET',
88+
headers: headers
89+
};
90+
get(credentials, options, fn)
91+
}
92+
93+
exports.kickUser = function (appId, roomName, userId, credentials, fn) {
94+
var options = {
95+
host: host,
96+
port: 80,
97+
path: '/v3/apps/' + appId + '/rooms/' + roomName + '/users/' + userId,
98+
method: 'DELETE',
99+
headers: headers
100+
};
101+
get(credentials, options, fn)
102+
}
103+
104+
exports.listActiveRoom = function (appId, roomNamePrefix, offset, limit, credentials, fn) {
105+
var options = {
106+
host: host,
107+
port: 80,
108+
path: '/v3/apps/' + appId + "/rooms?prefix=" + roomNamePrefix + "&offset=" + offset + "&limit=" + limit ,
109+
method: 'GET',
110+
headers: headers
111+
};
112+
get(credentials, options, fn)
113+
}
114+
115+
exports.roomToken = function (roomAccess, credentials) {
116+
if (!roomAccess.expireAt) {
117+
roomAccess.expireAt = Math.floor(Date.now() / 1000) + 3600;
118+
}
119+
return credentials.signJson(roomAccess);
120+
121+
}
122+

0 commit comments

Comments
 (0)