Skip to content

Commit

Permalink
chore: using top level await
Browse files Browse the repository at this point in the history
  • Loading branch information
Diluka committed Jan 4, 2022
1 parent 8b71ecd commit 0f1ee5b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ import { createCalendar } from './create-calendar.js';

const port = +process.env.SERVER_PORT || 3000;

(async () => {
let calendar = await createCalendar();
let calendar = await createCalendar();

setInterval(async () => {
calendar = await createCalendar();
}, 24 * 3600 * 1000);
setInterval(async () => {
calendar = await createCalendar();
}, 24 * 3600 * 1000);

http
.createServer((req, res) => calendar.serve(res))
.listen(port, () => {
console.log(`Server running at http://localhost:${port}/`);
});
})();
http
.createServer((req, res) => calendar.serve(res))
.listen(port, () => {
console.log(`Server running at http://localhost:${port}/`);
});

0 comments on commit 0f1ee5b

Please sign in to comment.