Implement an API call for getting the current stream key.
parent
df51432a8f
commit
f7c7f05786
18
docs/REST.md
18
docs/REST.md
|
@ -188,7 +188,9 @@ Notes: VODs are always available at http://domain.com/publicEndpoint/username/fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## /api/:user/config
|
### /api/:user/config
|
||||||
|
|
||||||
|
Get information about the specified user.
|
||||||
|
|
||||||
Method: GET
|
Method: GET
|
||||||
|
|
||||||
|
@ -202,8 +204,16 @@ Example: `{username: "foo", title: "bar", about: "This is an example bio"}`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Not Yet Implemented
|
|
||||||
|
|
||||||
#### /api/user/streamkey/current
|
#### /api/user/streamkey/current
|
||||||
|
|
||||||
Return current stream key
|
Returns current stream key for the authenticated user.
|
||||||
|
|
||||||
|
Method: GET
|
||||||
|
|
||||||
|
Authentication: yes
|
||||||
|
|
||||||
|
Parameters: none
|
||||||
|
|
||||||
|
Response: returns a JSON object with the stream key
|
||||||
|
|
||||||
|
Example: `{"stream_key": "abcdefghijklmno12345"}` or `{"error":"error reason"}`
|
13
src/http.ts
13
src/http.ts
|
@ -274,6 +274,19 @@ async function initAPI() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
app.get('/api/user/streamkey/current', (req, res) => {
|
||||||
|
validToken(req.cookies.Authorization).then((t) => {
|
||||||
|
if(t) {
|
||||||
|
db.query('SELECT stream_key FROM users WHERE username='+db.raw.escape(t['username'])).then(o => {
|
||||||
|
if(o[0]) res.send(o[0]);
|
||||||
|
else res.send('{"error":""}');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res.send('{"error":"invalid token"}');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
app.post('/api/user/streamkey', (req, res) => {
|
app.post('/api/user/streamkey', (req, res) => {
|
||||||
validToken(req.cookies.Authorization).then((t) => {
|
validToken(req.cookies.Authorization).then((t) => {
|
||||||
if(t) {
|
if(t) {
|
||||||
|
|
Reference in New Issue