Skip to content

Conversation

@demolaf
Copy link
Member

@demolaf demolaf commented Nov 19, 2025

Changes

1. No App Registry

  • Before: Had to manually track app instances
  • Now: FirebaseApp.getApp('myApp') works like Node.js

2. Services Weren't Cached

  • Before: Auth(app) created a new instance every time
  • Now: Returns the same instance (singleton pattern per app)

3. Manual Project ID Required

  • Before: FirebaseAdminApp.initializeApp(projectId, credential)
  • Now: Auto-discovers from credentials, env vars, or metadata server

4. No Proper Cleanup

  • Before: Services didn't clean up when app closed
  • Now: app.close() notifies all services to cleanup

5. Manual Emulator Setup

  • Before: Had to call app.useEmulator() manually
  • Now: Auto-detects from FIREBASE_*_EMULATOR_HOST env variables

6. No Named Apps

  • Before: Could only have one app
  • Now: initializeApp(options, name: 'secondary') like Node.js

Key Classes Introduced

  • ProjectIdProvider - Handles project ID discovery from multiple
    sources
  • AppRegistry - Manages app instances by name with lifecycle hooks
  • FirebaseApp - New app class with Node.js-compatible API
  • FirebaseService - Interface for proper service lifecycle
    management
  • AppOptions - Cleaner way to configure apps
  • AppException - Proper error handling for app-level errors
  • Environment - Handles environment detection and emulator config

Example Scripts

  • example/run_with_emulator.sh - Run example against emulators
  • example/run_with_prod.sh - Run example against production

@demolaf demolaf marked this pull request as draft November 19, 2025 15:48
@CLAassistant
Copy link

CLAassistant commented Nov 19, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

github-actions bot commented Nov 21, 2025

Coverage Report

✅ Coverage 54.93% meets 40% threshold

Coverage: 54.93%
Lines Covered: 2347/4273

Minimum threshold: 40%

@demolaf demolaf changed the title wip refactor FirebaseApp initialization logic refactor: initializeApp() with optional params, add multi-app support, service caching, and auto project ID discovery Nov 21, 2025
@demolaf demolaf marked this pull request as ready for review November 21, 2025 09:40
Copy link
Contributor

@Lyokone Lyokone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes

@Ehesp Ehesp changed the base branch from main to next November 23, 2025 17:13
- Splits API handling into HttpClient (low-level HTTP, emulator config, googleapis) and RequestHandler (business logic, transformations, validation).

- Improves separation of concerns across App Check, Auth, Firestore, Messaging, and Security Rules.
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.

5 participants