Skip to content

Commit

Permalink
fix: startup with no data
Browse files Browse the repository at this point in the history
  • Loading branch information
sachk committed Feb 5, 2024
1 parent 82d7497 commit ecd0558
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"timetableData":{},"courseWarnings":[],"lastUpdated":0}
4 changes: 4 additions & 0 deletions api/src/load-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const loadData = (eventType?: string) => {
}
};

if (!fs.existsSync(dataLocation)) {
fs.writeFileSync(dataLocation, JSON.stringify(data));
}

fs.watch(dataLocation, loadData);

loadData();
Expand Down

0 comments on commit ecd0558

Please sign in to comment.