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
|
||||
};
|
||||
|
||||
let cache = {};
|
||||
let cacheDate = 0;
|
||||
|
||||
if (mode == 'cli') {
|
||||
main(settings);
|
||||
} else if (mode == 'site') {
|
||||
const app = e();
|
||||
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");
|
||||
try {
|
||||
json = await json.json();
|
||||
} catch (err) {
|
||||
json = {};
|
||||
res.send(JSON.stringify({}));
|
||||
return;
|
||||
}
|
||||
|
||||
json = await json.json();
|
||||
|
||||
let { ref } = req.query;
|
||||
|
||||
|
@ -78,10 +63,7 @@ if (mode == 'cli') {
|
|||
dat2[d[0]] = d[1] * 100 + "%";
|
||||
}
|
||||
|
||||
cache = JSON.stringify(dat2);
|
||||
cacheDate = +(new Date);
|
||||
|
||||
res.send(cache)
|
||||
res.send(JSON.stringify(dat2))
|
||||
})
|
||||
|
||||
app.listen(port);
|
||||
|
|
Loading…
Reference in a new issue