Skip to content

Commit

Permalink
Fix startup with no data (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachk committed Feb 5, 2024
1 parent 82d7497 commit 8bf1c34
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import express from "express";
import cors from "cors";
import * as Sentry from "@sentry/node";
import * as Tracing from "@sentry/tracing";
import fs from "fs";
import { dataLocation } from "./load-data"

import * as notangles from "./notangles/index";
import * as freerooms from "./freerooms/index";
Expand Down Expand Up @@ -43,6 +45,15 @@ app.use((err, req, res, next) => {
res.end(res.sentry + "\n");
});

if(!fs.existsSync(dataLocation)) {
fs.writeFile(dataLocation, JSON.stringify({
timetableData: {},
courseWarnings: [],
lastUpdated: 0,
}));
}


app.listen(port, () => {
console.log(`App is running at http://localhost:${port}.`);
console.log("Press ctrl-c to stop.");
Expand Down

0 comments on commit 8bf1c34

Please sign in to comment.