mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
README.md update
This commit is contained in:
@@ -13,7 +13,7 @@ All requests return things on this form (results field is added if successful.)
|
|||||||
status: STATUSCODE,
|
status: STATUSCODE,
|
||||||
error: MESSAGE,
|
error: MESSAGE,
|
||||||
success: IF_SUCCESSFULL,
|
success: IF_SUCCESSFULL,
|
||||||
(results: RESULTS)
|
results: [RESULTS]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -74,14 +74,14 @@ PUT /api/conf/:channel_name
|
|||||||
{
|
{
|
||||||
"userpass": USER_PASSWORD,
|
"userpass": USER_PASSWORD,
|
||||||
"adminpass": PASSWORD,
|
"adminpass": PASSWORD,
|
||||||
"voting": BOOLEAN,
|
"vote": BOOLEAN,
|
||||||
"addsongs": BOOLEAN,
|
"addsongs": BOOLEAN,
|
||||||
"longsongs": BOOLEAN,
|
"longsongs": BOOLEAN,
|
||||||
"frontpage": BOOLEAN (if you want to set userpassword, this MUST be false for it to work),
|
"frontpage": BOOLEAN (if you want to set userpassword, this MUST be false for it to work),
|
||||||
"allvideos": BOOLEAN,
|
"allvideos": BOOLEAN,
|
||||||
"removeplay": BOOLEAN,
|
"removeplay": BOOLEAN,
|
||||||
"skipping": BOOLEAN,
|
"skip": BOOLEAN,
|
||||||
"shuffling": BOOLEAN,
|
"shuffle": BOOLEAN,
|
||||||
"userpass_changed": BOOLEAN (this must be true if you want to keep the userpassword you're sending)
|
"userpass_changed": BOOLEAN (this must be true if you want to keep the userpassword you're sending)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function list(msg, guid, coll, offline, socket) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
db.createCollection(coll, function(err, docs){
|
db.createCollection(coll, function(err, docs){
|
||||||
var configs = {"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "desc": ""};
|
var configs = {"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "desc": "", userpass: ""};
|
||||||
db.collection(coll + "_settings").insert(configs, function(err, docs){
|
db.collection(coll + "_settings").insert(configs, function(err, docs){
|
||||||
socket.join(coll);
|
socket.join(coll);
|
||||||
List.send_list(coll, socket, true, false, true);
|
List.send_list(coll, socket, true, false, true);
|
||||||
|
|||||||
@@ -37,42 +37,50 @@ var error = {
|
|||||||
status: 404,
|
status: 404,
|
||||||
error: "Couldn't find a song like that on YouTube.",
|
error: "Couldn't find a song like that on YouTube.",
|
||||||
success: false,
|
success: false,
|
||||||
|
results: [],
|
||||||
},
|
},
|
||||||
local: {
|
local: {
|
||||||
status: 404,
|
status: 404,
|
||||||
error: "Couldn't find a song like that in the channel",
|
error: "Couldn't find a song like that in the channel",
|
||||||
success: false,
|
success: false,
|
||||||
|
results: [],
|
||||||
},
|
},
|
||||||
list: {
|
list: {
|
||||||
status: 404,
|
status: 404,
|
||||||
error: "The list doesn't exist",
|
error: "The list doesn't exist",
|
||||||
success: false,
|
success: false,
|
||||||
|
results: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
not_authenticated: {
|
not_authenticated: {
|
||||||
status: 403,
|
status: 403,
|
||||||
error: "Wrong adminpassword or userpassword.",
|
error: "Wrong adminpassword or userpassword.",
|
||||||
success: false,
|
success: false,
|
||||||
|
results: [],
|
||||||
},
|
},
|
||||||
formatting: {
|
formatting: {
|
||||||
status: 400,
|
status: 400,
|
||||||
error: "Malformed request parameters.",
|
error: "Malformed request parameters.",
|
||||||
success: false,
|
success: false,
|
||||||
|
results: [],
|
||||||
},
|
},
|
||||||
conflicting: {
|
conflicting: {
|
||||||
status: 409,
|
status: 409,
|
||||||
error: "That element already exists.",
|
error: "That element already exists.",
|
||||||
success: false,
|
success: false,
|
||||||
|
results: [],
|
||||||
},
|
},
|
||||||
tooMany: {
|
tooMany: {
|
||||||
status: 429,
|
status: 429,
|
||||||
error: "You're doing too many requests, check header-field Retry-After for the wait-time left.",
|
error: "You're doing too many requests, check header-field Retry-After for the wait-time left.",
|
||||||
success: false,
|
success: false,
|
||||||
|
results: [],
|
||||||
},
|
},
|
||||||
no_error: {
|
no_error: {
|
||||||
status: 200,
|
status: 200,
|
||||||
error: false,
|
error: false,
|
||||||
success: true,
|
success: true,
|
||||||
|
results: [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,6 +209,7 @@ router.route('/api/conf/:channel_name').put(function(req, res) {
|
|||||||
typeof(allvideos) != "boolean" || typeof(removeplay) != "boolean" ||
|
typeof(allvideos) != "boolean" || typeof(removeplay) != "boolean" ||
|
||||||
typeof(skipping) != "boolean" || typeof(shuffling) != "boolean" ||
|
typeof(skipping) != "boolean" || typeof(shuffling) != "boolean" ||
|
||||||
typeof(userpass_changed) != "boolean") {
|
typeof(userpass_changed) != "boolean") {
|
||||||
|
console.log("crash here");
|
||||||
throw "Wrong format";
|
throw "Wrong format";
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -253,7 +262,7 @@ router.route('/api/conf/:channel_name').put(function(req, res) {
|
|||||||
{upsert:true}, function(err, docs){
|
{upsert:true}, function(err, docs){
|
||||||
updateTimeout(guid, res, "CONFIG", function(err, docs) {
|
updateTimeout(guid, res, "CONFIG", function(err, docs) {
|
||||||
var to_return = error.no_error;
|
var to_return = error.no_error;
|
||||||
to_return.results = obj;
|
to_return.results = [obj];
|
||||||
res.status(200).send(JSON.stringify(to_return));
|
res.status(200).send(JSON.stringify(to_return));
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
@@ -311,7 +320,7 @@ router.route('/api/list/:channel_name/:video_id').put(function(req,res) {
|
|||||||
List.getNextSong(channel_name, function() {
|
List.getNextSong(channel_name, function() {
|
||||||
updateTimeout(guid, res, "PUT", function(err, docs) {
|
updateTimeout(guid, res, "PUT", function(err, docs) {
|
||||||
var to_return = error.no_error;
|
var to_return = error.no_error;
|
||||||
to_return.results = song[0];
|
to_return.results = song;
|
||||||
res.status(200).send(JSON.stringify(to_return));
|
res.status(200).send(JSON.stringify(to_return));
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
@@ -357,7 +366,9 @@ router.route('/api/list/:channel_name/__np__').post(function(req, res) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updateTimeout(guid, res, "POST", function(err, docs) {
|
updateTimeout(guid, res, "POST", function(err, docs) {
|
||||||
res.status(200).send(JSON.stringify(list[0]));
|
var to_return = error.no_error;
|
||||||
|
to_return.results = list;
|
||||||
|
res.status(200).send(JSON.stringify(to_return));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -471,7 +482,7 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
|
|||||||
});
|
});
|
||||||
} else if(fetch_only) {
|
} else if(fetch_only) {
|
||||||
var to_return = error.no_error;
|
var to_return = error.no_error;
|
||||||
to_return.results = result[0];
|
to_return.results = result;
|
||||||
res.status(200).send(JSON.stringify(to_return));
|
res.status(200).send(JSON.stringify(to_return));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -531,7 +542,7 @@ router.route('/api/list/:channel_name/:video_id').get(function(req, res) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var to_return = error.no_error;
|
var to_return = error.no_error;
|
||||||
to_return.results = docs[0];
|
to_return.results = docs;
|
||||||
res.status(200).send(JSON.stringify(to_return));
|
res.status(200).send(JSON.stringify(to_return));
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
@@ -556,7 +567,7 @@ router.route('/api/conf/:channel_name').get(function(req, res) {
|
|||||||
} else {
|
} else {
|
||||||
conf.adminpass = false;
|
conf.adminpass = false;
|
||||||
}
|
}
|
||||||
if(conf.userpass != "") {
|
if(conf.userpass != "" && conf.userpass != undefined) {
|
||||||
conf.userpass = true;
|
conf.userpass = true;
|
||||||
} else {
|
} else {
|
||||||
conf.userpass = false;
|
conf.userpass = false;
|
||||||
@@ -785,7 +796,10 @@ function validateLogin(adminpass, userpass, channel_name, type, res, callback) {
|
|||||||
if(conf.length > 0 && ((conf[0].userpass == undefined || conf[0].userpass == "" || conf[0].userpass == userpass))) {
|
if(conf.length > 0 && ((conf[0].userpass == undefined || conf[0].userpass == "" || conf[0].userpass == userpass))) {
|
||||||
exists = true;
|
exists = true;
|
||||||
} else if(conf.length > 0 && type != "config") {
|
} else if(conf.length > 0 && type != "config") {
|
||||||
res.status(404).send(JSON.stringify(error.not_authenticated));
|
res.status(404).send(JSON.stringify(error.not_found.list));
|
||||||
|
return;
|
||||||
|
} else if(conf.length == 0) {
|
||||||
|
res.status(404).send(JSON.stringify(error.not_found.list));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,7 +827,7 @@ function postEnd(channel_name, configs, new_song, guid, res, authenticated) {
|
|||||||
List.getNextSong(channel_name, function() {
|
List.getNextSong(channel_name, function() {
|
||||||
updateTimeout(guid, res, "POST", function(err, docs) {
|
updateTimeout(guid, res, "POST", function(err, docs) {
|
||||||
var to_return = error.no_error;
|
var to_return = error.no_error;
|
||||||
to_return.results = new_song;
|
to_return.results = [new_song];
|
||||||
res.status(authenticated ? 200 : 403).send(JSON.stringify(to_return));
|
res.status(authenticated ? 200 : 403).send(JSON.stringify(to_return));
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user