Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates Firebase client for servers and workers #15

Merged
merged 4 commits into from
Sep 6, 2022

Conversation

willroberts
Copy link
Collaborator

@willroberts willroberts commented Aug 25, 2022

Summary

This PR upgrades the Firebase client for servers and workers, but not the client app yet. I'm still working out some Browserify issues with the new packages, so the client update will come in a followup PR.

Changes

  • Upgrades backend services from firebase v2.0.3 to firebase-admin v11.0.1, with the updated client caching "apps" instead of refs for improved connection reuse
  • Adds support for Google service accounts, replacing legacy tokens
  • Updates the config object to better group Firebase and JWT settings
  • Re-enables JWTs in the single player server
  • Adds new unit and integration tests for the Firebase client
  • Fixes some DB access / concurrency issues for migrations and tests
  • Allows setting FIREBASE_URL as a secret in .env for Docker services
  • Adds commands for running unit and integration tests in Docker
  • Gives each Docker service its own dependencies and environment variables
  • Adds a ssh vs https git workaround for NPM dependencies to docker/start

Test Results

Builds succeed, as do the Firebase tests:

$ mocha -t 1000 test/unit/firebase test/integration/firebase
CONFIG: version:1.96.17
CONFIG: env:development
CONFIG: firebase:<my-firebase-url>
CONFIG: postgres:0.0.0.0:5432/duelyst
CONFIG: redis:localhost

  Firebase.ServerClient.UnitTests
    #connect()
Firebase    | connect() -> new app connection with db
      ✔ should reject on empty firebase.url

  Firebase.ServerClient.IntegrationTests
Firebase    | connect() -> new app connection with db invalidurl
[2022-08-27T00:01:39.040Z]  @firebase/database: FIREBASE FATAL ERROR: Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com
    ✔ should reject on invalid firebase.url
Firebase    | connect() -> new app connection with db https://<my-firebase-url>/
Firebase    | disconnecting from https://<my-firebase-url>/
    ✔ should resolve on success
Firebase    | connect() -> new app connection with db https://<my-firebase-url>/
Firebase    | disconnecting from https://<my-firebase-url>/
    ✔ should avoid recreating existing connections
Firebase    | connect() -> new app connection with db https://<my-firebase-url>/
Firebase    | connect() -> new app connection with db https://another-duelyst-project.firebaseio.local/
Firebase    | disconnecting from https://<my-firebase-url>/
Firebase    | disconnecting from https://another-duelyst-project.firebaseio.local/
    ✔ should create new connections for new URLs
Firebase    | connect() -> new app connection with db https://<my-firebase-url>/
    ✔ should write test data
    ✔ should read back test data

  7 passing (69ms)

The tests result in data being written to my Firebase realtime DB, which I can see in the UI.

@willroberts willroberts force-pushed the firebase-backends branch 2 times, most recently from 25082a8 to 7e2e100 Compare August 25, 2022 04:19
@willroberts willroberts changed the title Updates Firebase on servers and workers Updates Firebase client for servers and workers Aug 25, 2022
@willroberts willroberts force-pushed the firebase-backends branch 3 times, most recently from 76421a3 to f70ca7b Compare August 26, 2022 23:07
@willroberts
Copy link
Collaborator Author

I just added another commit which improves error handling for the Firebase client and introduces a disconnect() method for tests.

@willroberts
Copy link
Collaborator Author

Pushed one more small commit to handle missing Google/Firebase service account keys a bit more gracefully.

@marwanhilmi
Copy link
Contributor

Awesome 💯 . Will review and merge today.

@marwanhilmi marwanhilmi merged commit 4adb4ef into open-duelyst:main Sep 6, 2022
@willroberts willroberts deleted the firebase-backends branch September 7, 2022 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants