Merge pull request #53 from ajayyy/experimental

Added post method for view counting and vote endpoints
This commit is contained in:
Ajay Ramachandran 2019-12-29 00:23:25 -05:00 committed by GitHub
commit 2f92efc44b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

Binary file not shown.

View file

@ -269,7 +269,10 @@ app.get('/api/postVideoSponsorTimes', async function (req, res) {
});
//voting endpoint
app.get('/api/voteOnSponsorTime', function (req, res) {
app.get('/api/voteOnSponsorTime', voteOnSponsorTime);
app.post('/api/voteOnSponsorTime', voteOnSponsorTime);
function voteOnSponsorTime(req, res) {
let UUID = req.query.UUID;
let userID = req.query.userID;
let type = req.query.type;
@ -432,10 +435,13 @@ app.get('/api/voteOnSponsorTime', function (req, res) {
res.sendStatus(200);
});
});
});
}
//Endpoint when a sponsorTime is used up
app.get('/api/viewedVideoSponsorTime', function (req, res) {
app.get('/api/viewedVideoSponsorTime', viewedVideoSponsorTime);
app.post('/api/viewedVideoSponsorTime', viewedVideoSponsorTime);
function viewedVideoSponsorTime(req, res) {
let UUID = req.query.UUID;
if (UUID == undefined) {
@ -448,7 +454,8 @@ app.get('/api/viewedVideoSponsorTime', function (req, res) {
db.prepare("UPDATE sponsorTimes SET views = views + 1 WHERE UUID = ?").run(UUID);
res.sendStatus(200);
});
}
//To set your username for the stats view
app.post('/api/setUsername', function (req, res) {