Skip to content

Commit

Permalink
feat: update every 1 hr
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Dec 24, 2024
1 parent bb3481a commit 3257749
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ app.use(cors({

let f = new Fetcher();
(async function run() {
await f.run();
await f.loop();
}());

app.get('/api/rewards/all/', (req, res) => {
Expand Down
6 changes: 5 additions & 1 deletion src/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,18 @@ export class Fetcher {


async run() {
console.log("updating fetcher")
for (var network of Object.values(supportedChains)) {
let chainId = CHAINS[network as NetworkType];
let apys = await this.getnetworkTokens(network as NetworkType);
this.cache[chainId] = apys;
}
}


async loop() {
this.run();
setInterval(this.run.bind(this), 60 * 60 * 1000); // 1 hr
}
}


Expand Down

0 comments on commit 3257749

Please sign in to comment.