aler9-server-manager
Advanced tools
Comparing version 0.0.3 to 0.0.4
70
index.js
@@ -8,2 +8,4 @@ "use strict"; | ||
this.uri = cfg.uri; | ||
else | ||
throw new Error('uri is required'); | ||
} | ||
@@ -20,2 +22,12 @@ async getConfig() { | ||
} | ||
async getPaths() { | ||
const pathList = await fetch(this.uri + '/v1/paths/list', { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const data = await pathList.json(); | ||
return data; | ||
} | ||
async addPath(pathName, path) { | ||
@@ -33,3 +45,3 @@ const addPathToServer = await fetch(this.uri + '/v1/config/paths/add/' + pathName, { | ||
async editPath(pathName, path) { | ||
const addPathToServer = await fetch(this.uri + '/v1/config/paths/edit/' + pathName, { | ||
const editPathOnServer = await fetch(this.uri + '/v1/config/paths/edit/' + pathName, { | ||
method: 'POST', | ||
@@ -41,7 +53,7 @@ headers: { | ||
}); | ||
const data = await addPathToServer.json(); | ||
const data = await editPathOnServer.json(); | ||
return data; | ||
} | ||
async deletePath(pathName) { | ||
const addPathToServer = await fetch(this.uri + '/v1/config/paths/remove/' + pathName, { | ||
const deletePathFromServer = await fetch(this.uri + '/v1/config/paths/remove/' + pathName, { | ||
method: 'POST', | ||
@@ -52,7 +64,57 @@ headers: { | ||
}); | ||
const data = await addPathToServer.json(); | ||
const data = await deletePathFromServer.json(); | ||
return data; | ||
} | ||
async getRtspConnections() { | ||
const rtspConnections = await fetch(this.uri + '/v1/rtspconns/list', { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const data = await rtspConnections.json(); | ||
return data; | ||
} | ||
async getRtspSessions() { | ||
const rtspSessions = await fetch(this.uri + '/v1/rtspsessions/list', { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const data = await rtspSessions.json(); | ||
return data; | ||
} | ||
async getWebrtcConnections() { | ||
const webrtcConnections = await fetch(this.uri + '/v1/webrtcconns/list', { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const data = await webrtcConnections.json(); | ||
return data; | ||
} | ||
async kickRtspSession(kick_id) { | ||
const webrtcConnections = await fetch(this.uri + '/v1/rtspsessions/kick/' + kick_id, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const data = await webrtcConnections.json(); | ||
return data; | ||
} | ||
async kickWebrtcConnection(kick_id) { | ||
const webrtcConnections = await fetch(this.uri + '/v1/webrtcconns/kick/' + kick_id, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const data = await webrtcConnections.json(); | ||
return data; | ||
} | ||
} | ||
exports.default = Aler9StreamServer; | ||
//# sourceMappingURL=index.js.map |
105
index.ts
@@ -166,2 +166,36 @@ export type TAler9Config = { | ||
export type TPathList = { | ||
items: { | ||
[x: string]: { | ||
created: string | ||
remoteAddr: string | ||
bytesReceived: number | ||
bytesSent: number | ||
} | ||
} | ||
} | ||
export type TConnections = { | ||
items: { | ||
[x: string]: { | ||
created: string | ||
remoteAddr: string | ||
bytesReceived: number | ||
bytesSent: number | ||
} | ||
} | ||
} | ||
export type TRTSPSessions = { | ||
items: { | ||
[x: string]: { | ||
created: string | ||
remoteAddr: string | ||
bytesReceived: number | ||
bytesSent: number | ||
state: string | ||
} | ||
} | ||
} | ||
export default class Aler9StreamServer { | ||
@@ -171,3 +205,5 @@ uri: string = '' | ||
if (cfg.uri) this.uri = cfg.uri | ||
else throw new Error('uri is required') | ||
} | ||
async getConfig() { | ||
@@ -183,2 +219,12 @@ const config = await fetch(this.uri + '/v1/config/get', { | ||
} | ||
async getPaths() { | ||
const pathList = await fetch(this.uri + '/v1/paths/list', { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
const data: TPathList = await pathList.json() | ||
return data | ||
} | ||
async addPath(pathName: string, path: TAler9PathAddOrEdit) { | ||
@@ -196,3 +242,3 @@ const addPathToServer = await fetch(this.uri + '/v1/config/paths/add/' + pathName, { | ||
async editPath(pathName: string, path: TAler9PathAddOrEdit) { | ||
const addPathToServer = await fetch(this.uri + '/v1/config/paths/edit/' + pathName, { | ||
const editPathOnServer = await fetch(this.uri + '/v1/config/paths/edit/' + pathName, { | ||
method: 'POST', | ||
@@ -204,7 +250,7 @@ headers: { | ||
}) | ||
const data = await addPathToServer.json() | ||
const data = await editPathOnServer.json() | ||
return data | ||
} | ||
async deletePath(pathName: string) { | ||
const addPathToServer = await fetch(this.uri + '/v1/config/paths/remove/' + pathName, { | ||
const deletePathFromServer = await fetch(this.uri + '/v1/config/paths/remove/' + pathName, { | ||
method: 'POST', | ||
@@ -215,5 +261,56 @@ headers: { | ||
}) | ||
const data = await addPathToServer.json() | ||
const data = await deletePathFromServer.json() | ||
return data | ||
} | ||
async getRtspConnections() { | ||
const rtspConnections = await fetch(this.uri + '/v1/rtspconns/list', { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
const data: TConnections = await rtspConnections.json() | ||
return data | ||
} | ||
async getRtspSessions() { | ||
const rtspSessions = await fetch(this.uri + '/v1/rtspsessions/list', { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
const data: TRTSPSessions = await rtspSessions.json() | ||
return data | ||
} | ||
async getWebrtcConnections() { | ||
const webrtcConnections = await fetch(this.uri + '/v1/webrtcconns/list', { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
const data: TConnections = await webrtcConnections.json() | ||
return data | ||
} | ||
async kickRtspSession(kick_id: string) { | ||
const webrtcConnections = await fetch(this.uri + '/v1/rtspsessions/kick/' + kick_id, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
const data = await webrtcConnections.json() | ||
return data | ||
} | ||
async kickWebrtcConnection(kick_id: string) { | ||
const webrtcConnections = await fetch(this.uri + '/v1/webrtcconns/kick/' + kick_id, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
const data = await webrtcConnections.json() | ||
return data | ||
} | ||
} |
{ | ||
"name": "aler9-server-manager", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "aler9 multiprotocol media server API manager", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
42480
1023
10