Implement an API call for getting the current stream key.

This commit is contained in:
knotteye
2020-07-30 01:34:22 -05:00
parent df51432a8f
commit f7c7f05786
2 changed files with 27 additions and 4 deletions

View File

@@ -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) => {
validToken(req.cookies.Authorization).then((t) => {
if(t) {