diff --git a/.gitignore b/.gitignore index d8d7dc2..f923245 100644 --- a/.gitignore +++ b/.gitignore @@ -64,5 +64,4 @@ node_modules/ # dotenv environment variables file .env -./src/api/firebase.js firebase.js \ No newline at end of file diff --git a/README.md b/README.md index 7308394..b373541 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,20 @@ # Running Build & Deploying it to Firebase `npm run build && firebase deploy` +# Running Firebase Tests +`cd functions && npm run test` + +# Running Locally +1. Ensure you have Java 11 or greater installed. +2. Run `npm install` in the traintracker directory. +3. Run `npm install` in the functions directory. +4. Start the emulator (needed to emulate the functions locally) `firebase emulators:start &` (the `&` forks it into the background). +5. Run `npm run dev` +You will need to click the "Populate Database" and "Fetch Data" buttons to get data into your local version of the webapp. + +To kill the npm process do `CTRL + C` in your terminal. +To kill the firebase emulators run `fg` to bring the process to the foreground, then do `CTRL + C` + # Committing Make sure that you exclude the Firebase API key from any commits! diff --git a/functions/index.js b/functions/index.js index ef9aa38..c40b6e0 100644 --- a/functions/index.js +++ b/functions/index.js @@ -18,7 +18,7 @@ exports.getLiveTrainData = functions.https.onRequest((request, response) => { // fetch the "liveTrainData" collection admin.firestore().collection('liveTrainData').get().then((snapshot) => { if (snapshot.empty) { - response.send({data: "Error fetching live train data from the database"}); + response.status(404).send({data: "Error fetching live train data from the database"}); return; } // iterate through each of the collection's documents @@ -40,7 +40,7 @@ exports.getStationData = functions.https.onRequest((request, response) => { // fetch the "stations" collection admin.firestore().collection('stations').get().then((snapshot) => { if (snapshot.empty) { - response.send({data: "Error fetching station data from the database"}) + response.status(404).send({data: "Error fetching station data from the database"}) return; } // iterate through each of the collection's documents diff --git a/src/components/Map.vue b/src/components/Map.vue index 9380078..09dc85e 100644 --- a/src/components/Map.vue +++ b/src/components/Map.vue @@ -1,4 +1,12 @@