diff --git a/README.MD b/README.MD index e2a2b6c..2511ea2 100644 --- a/README.MD +++ b/README.MD @@ -8,7 +8,7 @@ This is the server backend for it This is a simple Sqlite database that will hold all the timing data. -To make sure that this project doesn't die, I have made the database publicly downloadable at https://api.sponsor.ajay.app/database.db (formerly https://sponsor.ajay.app/database.db). You can download a backup or get archive.org to take a backup if you do desire. The database is under [this license](https://creativecommons.org/licenses/by-nc-sa/4.0/) unless you get explicit permission from me. +To make sure that this project doesn't die, I have made the database publicly downloadable at https://sponsor.ajay.app/database.db. You can download a backup or get archive.org to take a backup if you do desire. The database is under [this license](https://creativecommons.org/licenses/by-nc-sa/4.0/) unless you get explicit permission from me. Hopefully this project can be combined with projects like [this](https://github.com/Sponsoff/sponsorship_remover) and use this data to create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea. diff --git a/src/app.js b/src/app.js index 3c7ec8a..9561dc1 100644 --- a/src/app.js +++ b/src/app.js @@ -26,7 +26,6 @@ var getDaysSavedFormatted = require('./routes/getDaysSavedFormatted.js'); var oldGetVideoSponsorTimes = require('./routes/oldGetVideoSponsorTimes.js'); var oldSubmitSponsorTimes = require('./routes/oldSubmitSponsorTimes.js'); - //setup CORS correctly app.use(corsMiddleware); app.use(loggerMiddleware); @@ -35,6 +34,9 @@ app.use(express.json()) // Setup pretty JSON if (config.mode === "development") app.set('json spaces', 2); +// Set production mode +app.set('env', config.mode || 'production'); + //add the get function app.get('/api/getVideoSponsorTimes', oldGetVideoSponsorTimes); @@ -82,10 +84,10 @@ app.get('/api/getTopUsers', getTopUsers); app.get('/api/getTotalStats', getTotalStats); //send out a formatted time saved total -app.get('/api/getdayssavedformatted', getDaysSavedFormatted); +app.get('/api/getDaysSavedFormatted', getDaysSavedFormatted); app.get('/database.db', function (req, res) { - res.sendfile("./databases/sponsortimes.db", { root: __dirname }); + res.sendFile("./databases/sponsorTimes.db", { root: "./" }); }); // Create an HTTP service. diff --git a/src/routes/getDaysSavedFormatted.js b/src/routes/getDaysSavedFormatted.js index 7fece0c..45f13d8 100644 --- a/src/routes/getDaysSavedFormatted.js +++ b/src/routes/getDaysSavedFormatted.js @@ -1,12 +1,12 @@ -var db = require('../databases/databases.js'); +var db = require('../databases/databases.js').db; module.exports = function getDaysSavedFormatted (req, res) { - let row = db.prepare("select sum((endtime - starttime) / 60 / 60 / 24 * views) as dayssaved from sponsortimes where shadowhidden != 1").get(); + let row = db.prepare("SELECT SUM((endTime - startTime) / 60 / 60 / 24 * views) as daysSaved from sponsorTimes where shadowHidden != 1").get(); if (row !== undefined) { //send this result res.send({ - dayssaved: row.dayssaved.tofixed(2) + daysSaved: row.daysSaved.toFixed(2) }); } -} \ No newline at end of file +} diff --git a/test.js b/test.js index 3a13418..a5f09b0 100644 --- a/test.js +++ b/test.js @@ -34,7 +34,7 @@ var mockServer = createMockServer(() => { mocha.run(function(failures) { mockServer.close(); server.close(); - process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures + process.exit(failures ? 1 : 0); // exit with non-zero status if there were failures }); }); });