add stats api for homepage widget

This commit is contained in:
Karl0ss 2023-06-07 14:35:54 +01:00
parent f0a949aacb
commit 84180b066e

28
routes/api.js Normal file
View File

@ -0,0 +1,28 @@
const fs = require("fs");
const { nextLinkCheck, nextRssRefresh, get_last_downloaded } = require('.././utils')
module.exports = function (app) {
app.get("/api/stats", (req, res) => {
retryCache = JSON.parse(fs.readFileSync('./cache/retryCache.json'))
for (let index = 0; index < retryCache.length; index++) {
const item = retryCache[index];
retryCache[index].newtitle = item.title.replace(/ /g, "‡");
}
showList = JSON.parse(fs.readFileSync('shows.json'));
feedCache = JSON.parse(fs.readFileSync('./cache/feedCache.json'));
rssTime = nextRssRefresh()
linkCheck = nextLinkCheck()
lastDownloaded = get_last_downloaded()
res.json({
"ShowList": showList.length,
"FeedCache": feedCache.length,
"RetryCache": retryCache.length,
"RSSCheck": rssTime,
"LinkChecker": linkCheck,
"LastDownloaded": lastDownloaded
});
});
}