Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
1 changed files with 2 additions and 20 deletions
22
index.js
22
index.js
|
@ -26,28 +26,13 @@ let settings = {
|
||||||
arrayMax
|
arrayMax
|
||||||
};
|
};
|
||||||
|
|
||||||
let cache = {};
|
|
||||||
let cacheDate = 0;
|
|
||||||
|
|
||||||
if (mode == 'cli') {
|
if (mode == 'cli') {
|
||||||
main(settings);
|
main(settings);
|
||||||
} else if (mode == 'site') {
|
} else if (mode == 'site') {
|
||||||
const app = e();
|
const app = e();
|
||||||
app.get('/top', async (req, res) => {
|
app.get('/top', async (req, res) => {
|
||||||
if ((new Date) - cacheDate < 1000*1) {
|
|
||||||
res.send(cache);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let json = await fetch("https://nbg.dervland.net/api/followjson.php");
|
let json = await fetch("https://nbg.dervland.net/api/followjson.php");
|
||||||
try {
|
json = await json.json();
|
||||||
json = await json.json();
|
|
||||||
} catch (err) {
|
|
||||||
json = {};
|
|
||||||
res.send(JSON.stringify({}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let { ref } = req.query;
|
let { ref } = req.query;
|
||||||
|
|
||||||
|
@ -78,10 +63,7 @@ if (mode == 'cli') {
|
||||||
dat2[d[0]] = d[1] * 100 + "%";
|
dat2[d[0]] = d[1] * 100 + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
cache = JSON.stringify(dat2);
|
res.send(JSON.stringify(dat2))
|
||||||
cacheDate = +(new Date);
|
|
||||||
|
|
||||||
res.send(cache)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.listen(port);
|
app.listen(port);
|
||||||
|
|
Loading…
Reference in a new issue