Added a funny 404 page

This commit is contained in:
Kasper Rynning-Tønnesen
2017-11-14 12:24:09 +01:00
parent 7b0d3c3232
commit 1adff62a45
3 changed files with 14 additions and 7 deletions

View File

@@ -55,7 +55,9 @@ function list(msg, guid, coll, offline, socket) {
}); });
} else { } else {
db.createCollection(coll, function(err, docs){ db.createCollection(coll, function(err, docs){
db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "desc": ""}, 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": ""};
db.collection(coll).insert(configs, function(err, docs){
socket.join(coll);
List.send_list(coll, socket, true, false, true); List.send_list(coll, socket, true, false, true);
db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": Functions.get_time()}); db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": Functions.get_time()});
}); });
@@ -361,7 +363,6 @@ function send_list(coll, socket, send, list_send, configs, shuffled)
} }
}); });
if(configs) if(configs)
{ {
if(conf[0].adminpass !== "") conf[0].adminpass = true; if(conf[0].adminpass !== "") conf[0].adminpass = true;

View File

@@ -129,6 +129,10 @@ app.use('/', router);
app.use('/assets', express.static(publicPath + '/assets')); app.use('/assets', express.static(publicPath + '/assets'));
app.use(function (req, res, next) {
res.status(404).redirect("/404");
})
db.on('error',function(err) { db.on('error',function(err) {
console.log("\n" + new Date().toString() + "\n Database error: ", err); console.log("\n" + new Date().toString() + "\n Database error: ", err);
}); });

View File

@@ -25,8 +25,9 @@ router.route('/api/list/:channel_name').get(function(req, res) {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(docs)); res.send(JSON.stringify(docs));
} else { } else {
res.status(404); /*res.status(404);
res.send(404); res.send(404);*/
res.status(404).redirect("/404");
} }
}); });
}); });
@@ -62,8 +63,9 @@ router.route('/api/conf/:channel_name').get(function(req, res) {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(conf)); res.send(JSON.stringify(conf));
} else { } else {
res.status(404); /*res.status(404);
res.send(404); res.send(404);*/
res.status(404).redirect("/404");
} }
}); });
}); });