Skip to content

Commit

Permalink
fix: instantiate fetch interval only after first fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
cirex-web committed Feb 22, 2025
1 parent c8bd294 commit 32b693b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,13 @@ app.get("/locations/time/:day/:hour/:min", ({ params: { day, hour, min } }) => {
return { locations: result };
});

// Update the cache every 10 minutes
const interval = 1000 * 60 * 10;
setInterval(() => {
reload().catch(console.error);
}, interval);

// Initial load and start the server
reload().then(() => {
app.listen(PORT);

const interval = 1000 * 60 * 10; // 10 minutes
setInterval(() => {
reload().catch(console.error);
}, interval);
console.log(
`Dining API is running at ${app.server?.hostname}:${app.server?.port}`
);
Expand Down

0 comments on commit 32b693b

Please sign in to comment.