Earlier this week I decided to pause progress of my microservice today to instead test @humphd’s dockerized Firebase emulator. I needed to ensure this works for three two reasons:
To get a grade in OSD700 by testing a PR- To ensure that I could insert data into a local, traefik, dockeriz’d, offline, version of the Firebase Firestore.
- To ensure a smooth integration into my User microservice.
Last week I participated in a hackathon and used Firebase as my db of choice. I ran into some issues that were preventing me from inserting data into my local version of the db. I had assumed that this was due to the fact that I had never specified a private API key to use. This is a big issue as having to specify a private API key to use the offline emulator means that we have to authenticate each and every developer who needs to use Firestore (this also ruins our potential CI pipeline.) Assuming the worst, I reported my grim findings during our triage meeting on Tuesday.
Evidently this is not the case as I did not specify one when testing this PR. Hopefully the fact that the emulated version now works is due to PEBKAC, RTFM, or both. I need to release a draft PR in order to get more devs to test my code.
I tested this PR by making a separate (i.e. bastardized) version of my current microservice work that I use to send data to my Firestore, and pointing it to the dockerized version. It sounds simple but there were a few things that I had to do first: I had to lighty reintroduce myself to Docker, fix my Ubuntu WSL2 install (god I need to get Ubuntu working with my fakeraid system…), and do some reading and catching up about Firestore Emulator. After some time I finally got it to work and reported by findings on the PR.
Anyway, testing this PR was a lot of fun and a headache at the same time. I imagine this feeling is a lot like raising children.
After finishing my review, I proceeded to continue working my microservice. It’s finally nearing a point where I can release it to the wild for review. I needed (and am eternally grateful for) guidance, direction, and help to push this thing into a PR. The only thing that I lack now is time. Time, and brain cells mostly. It’s getting late in the week and the last 10% of something always takes as much time as the 90% did. Well, maybe not 90% in this case, but it sure felt like it given all the work I’ve rushed into this in the last few days.
Here is my leftover todo list:
- Finish up making some more tests, specifically ones that test Celebrate’s validation rules a. Mostly done. I still could use several tests testing various smaller bits of code but those can always be added in later and spending too much time on this won’t get a PR up sooner.
- Migrate to https://www.npmjs.com/package/@firebase/rules-unit-testing because
@firebase/testing
is deprecated a. Done. - Create a basic README.md file a. Done. I’m rather proud of it actually. It does need some more work as I need to specify exactly how the service and docker + traefik work together to get data where it needs to go.
- Implement a list of current deficiencies and issues to discuss when the draft PR goes up a. Done. Kind of. I’ve been keeping track of this but at lot of them have been fixed and a lot of things have changed in the last few days.
- Implement Satellite
a. Done. I was having some issues with this though, as after implementing Satellite all my tests were failing. My problem, as expected, was minor and silly:
const { app } = require('../../index');
, I wasn’t de-structuringapp
fromindex
, so all the function calls were failing as they didn’t exist inapp
. - Dockerize the microservice a. Done. I’m a great admirer of Docker (and traefik) but it’s still confusing to me. I just need more experience. Mostly I lack the context of how things are interconnected to each other via multiple Dockers + Traefik.
- Add Firestore private key placeholders to
env.production
andenv.staging
a. Not done. I’m lacking both files so I’ll need to iterate on this. Thanks, checklist! Tidy up thea. Unnecessary since the entire microservice is run via Docker, having npm run commands are a thing of the past.package.json
run commands using npm-run-all- Create an update (put) route a. Done, along with accompanying tests.
- Create a delete route a. Done, along with accompanying tests.
Add date/time users were created (mostly for funsies)a. Not done. Scrapped for time.Add date/time users were updated (again, for funsies)a. Not done. Scrapped for time.- Migrate unnecessary
package.json
dependencies to dev-dependencies a. Done. - Finally, create a PR! a. Done!
So now that the microservice is finally up, I’m hoping for a lot of feedback. I still have things that I need to fix, though mostly minor things and documentation edits. I have a few tests that need to pass, and I’m hoping to make the time for it this week around my work schedule. I’d also like to expand on how exactly to test the PR on the PR page. Sometimes it’s hard to translate what little goes on in my head, to fingers and keyboard.
Something else that needs answers that I didn’t think about until now: How do I ensure my delete route can only be ran by admins? Any fellow proletariat can execute the bourgeoisie a delete route and delete a bunch of users. Questions, questions that need answers and riddles in the dark.
Minor list of things that did dun need doing:
-
Create a
env.production
andenv.staging
file -
Clean up the readme
-
Fix the Dockerfile
-
Add a section on how to test the PR (on the PR page)
-
Fix the failing tests
- Expected value: {“displayName”: “Galileo Galilei”, “feeds”: [“https://dev.to/feed/galileogalilei”], “firstName”: “Galileo”, “github”: {“avatarUrl”: “https://avatars.githubusercontent.com/u/7242003?s=460&u=733c50a2f50ba297ed30f6b5921a511c2f43bfee&v=4", “username”: “galileogalilei”}, “id”: 10001, “isAdmin”: true, “isFlagged”: true, “lastName”: “Galilei”} vs.
- Received object: {“feeds”: [“https://dev.to/feed/galileogalilei”], “firstName”: “Galileo”, “github”: {“avatarUrl”: “https://avatars.githubusercontent.com/u/7242003?s=460&u=733c50a2f50ba297ed30f6b5921a511c2f43bfee&v=4", “username”: “galileogalilei”}, “id”: 10001, “isAdmin”: true, “isFlagged”: true, “lastName”: “Galilei”}
-
How are we going to do security?
-
Switch my port to 7777 since SOMEONE took my satanic panic port 6666, my disappointment is immeasurable and my day Is ruined.
Oh, and I just reviewed Tony’s microservice! I unfortunately missed out on Abdul’s and I kept my head buried in the sand for the last week or so trying to finish this up, so I’m glad I got to play around with someone else’s. Got looks like a sweet library, that plus celebrate is really turning me towards NodeJS development.
Anyway that’s it for me right now. Fun but busy week, and as always looking forward to the next one.