Skip to content

Commit

Permalink
More doc for [Emulator] and make the constructor public.
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-chang committed Jun 10, 2024
1 parent 20f11f8 commit 46749f3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/dart_firebase_admin/lib/src/app/emulator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ part of '../app.dart';
/// Represents a Firebase Emulator.
/// Now for Auth and Firestore.
class Emulator {
const Emulator._(this.host, this.port);

/// If there is no environment variable set, please use this constructor.
/// For example, gcloud firestore emulators.
const Emulator(this.host, this.port);

/// The default Auth Emulator.
const Emulator.defaultAuth()
: host = '127.0.0.1',
port = 9099;

/// The default Firestore Emulator.
const Emulator.defaultFirestore()
: host = '127.0.0.1',
port = 8080;

/// Creates an [Emulator] from a firebase environment variable.
/// For example, env key for auth is: FIREBASE_AUTH_EMULATOR_HOST
factory Emulator.fromEnvString(String envString) {
final parts = envString.split(':');
if (parts.length != 2) {
Expand All @@ -23,7 +30,7 @@ class Emulator {
if (port == null) {
throw ArgumentError.value(envString, 'envString', 'Invalid port');
}
return Emulator._(host, port);
return Emulator(host, port);
}

final String host;
Expand Down

0 comments on commit 46749f3

Please sign in to comment.