poplocrel

This commit is contained in:
matteo
2019-03-03 20:54:14 +01:00
parent d9d6138fd9
commit 99c948f7b5
+8 -16
View File
@@ -109,18 +109,11 @@ low(new FileAsync(__dirname + '/db.json')) // production
'Access-Control-Allow-Origin': '*'
});
let setReason = function (reason='Starter', oldArr = [], prevId) {
// if (oldObj.hasOwnProperty(reason, prevId)) {
// ++oldObj[reason];
// return oldObj;
// }
// else {
// Object.defineProperty(oldObj,
// reason, { value: 1, enumerable: true, writable: true }
// )
// return oldObj;
// }
let j=oldArr.findIndex(el=>el.prevId===prevId && el.reason===reason)
if (j>=0) {++oldArr[j].timesWatched; return oldArr}
if (j>=0) {
++oldArr[j].timesWatched;
return oldArr
}
else {
let tmp={
prevId,
@@ -130,7 +123,6 @@ low(new FileAsync(__dirname + '/db.json')) // production
oldArr.push(tmp)
return oldArr
}
}
const videos = db.get('videos');
@@ -157,9 +149,9 @@ low(new FileAsync(__dirname + '/db.json')) // production
return db.defaults({ videos: [] }).write();
})
.then(() => {
//app.use(express.static(__dirname + '/build')); // serve static build site
//app.get('*', (req, res) => {
// res.sendFile(__dirname + '/build/index.html');
//});
app.use(express.static(__dirname + '/build')); // serve static build site
app.get('*', (req, res) => {
res.sendFile(__dirname + '/build/index.html');
});
app.listen(8000, () => console.log('listen on 8000')); // bind to port 8000 as required from specs
});