advweb-grp1 / advanced-web-final-year-project

Final year advanced web develop unit project
MIT License
1 stars 0 forks source link

core: Fire store setup #17

Closed rwx-yxu closed 1 year ago

rwx-yxu commented 1 year ago

Get the initial config to make firestore accessible.

Main objectives are to make main compatible with .env files for the fire store config.

I need to make the documents and collections manually in the firebase console as well.

rwx-yxu commented 1 year ago

The CSV file provided to us for hcm is left to the developers to decide on how we want to process the data.

rwx-yxu commented 1 year ago

I am thinking of potentially having node check for the presence of the file in the root directory. If there is a 'hcm.csv' file, then parse the data into firestore. Otherwise start up and check that the the application can ping the db.

rwx-yxu commented 1 year ago

Will work on the happy path first with the firestore configs before parsing or checking on start up.

rwx-yxu commented 1 year ago

TODO:

rwx-yxu commented 1 year ago

There are larger implications how that I think about the .env file because I think that for this assignment, we need to make that available on the repo but I do not feel comfortable with putting API keys on a public GitHub repo.

Need to think of a way to have something like a .env.local file for dev and allow for .env to be pushed to the repo once the project is done.

rwx-yxu commented 1 year ago

Instead of a test document, would it be more sensible to have a "Setup" document that has values that tracks if the app has been setup? I could still have the test key value but, I could also have a key value for "{hcm_data_uploaded:false}"? So, in the app, I check for that and if it is false, I find the csv and parse it to post onto the db. This would be better than a standalone script that is a throw away and it wouldn't be a throwaway end point that we would have open.

LiamSingh64 commented 1 year ago

Need to think of a way to have something like a .env.local file for dev and allow for .env to be pushed to the repo once the project is done.

So the pushed .env file will just access variables from the .env.local file?

rwx-yxu commented 1 year ago

No. The .env file is one that is available publicly. .env.local file will just be for local development that is not pushed to GitHub. Reason for making the .env file public is because I think that Ismail wants the config files for firebase visible along with the account passwords ect for the adv-grp1 accounts so we need to make a .env file publicly visible.

rwx-yxu commented 1 year ago

We will use .env.local for now and make push .env file public at the end of the project.

.env to be pushed to the repo once the project is done.

Wouldn't want the firebase config settings to be pushed right now during development. Saves time with putting .env in .gitignore now and then taking it off at the end to push .env. Whereas I can put .env.local in .gitignore and not bother with messing with that file at all.

rwx-yxu commented 1 year ago

Noticed that there is already a branch for core/fire-base-setup. Need to check with @LiamSingh64 on if he wants to dev it since he already has two commits in there. Branch was created without telling me despite the issue assigned to myself because I have access to adv-grp1 firebase account for the config info.....

rwx-yxu commented 1 year ago

Taking back ownership of dev after clarifying Liams stance. Since he wanted to make a start and leave it at that without informing me.

rwx-yxu commented 1 year ago

Liam had already pushed the .env file to source control. I think I'll add in a IS_DEVELOPMENT=false variable in there as a toggle between this .env or the .env.local file.

rwx-yxu commented 1 year ago

Vite has a way to manage env files https://vitejs.dev/guide/env-and-mode.html

rwx-yxu commented 1 year ago

Wont even need the toggle. Vite will auto import a .env file along with .env.local files.

rwx-yxu commented 1 year ago

Going to use csv-parser to parse the csv and fs to find the csv in the current directory.

rwx-yxu commented 1 year ago

Trying to do the parsing right now and I am getting this error when trying to use fs to read the file Cannot access "fs.existsSync" in client code.

rwx-yxu commented 1 year ago

Starting to learn that there is a difference between vite and nodejs. vite is the frontend development server which runs in the browser means that it is separate from the server side nodejs. This means that vite cannot have direct access to server files and cannot exit using process.exit(1).

rwx-yxu commented 1 year ago

This means that I am gonna need to write uploadHcmData.js as a standalone script and put the script command in package,json as a node script so that node can have access to local files.

rwx-yxu commented 1 year ago

Not sure if it is worthwhile to upload the hcm csv file

rwx-yxu commented 1 year ago

verified that the data has been uploaded to firestore. image