23
23
import firebase_functions .private .path_pattern as _path_pattern
24
24
import firebase_functions .core as _core
25
25
import cloudevents .http as _ce
26
- import firebase_admin as _fa
27
- import firebase_admin .db as _db
28
26
29
- from firebase_admin .db import Reference
30
27
from firebase_functions .options import DatabaseOptions
31
28
from firebase_functions .core import Change , T
32
29
@@ -52,9 +49,9 @@ class Event(_core.CloudEvent[T]):
52
49
The instance ID portion of the fully qualified resource name.
53
50
"""
54
51
55
- reference : Reference
52
+ reference : str
56
53
"""
57
- The database reference.
54
+ The database reference path .
58
55
"""
59
56
60
57
location : str
@@ -99,24 +96,16 @@ def _db_endpoint_handler(
99
96
before = before ,
100
97
after = after ,
101
98
)
102
- if _fa ._DEFAULT_APP_NAME not in _fa ._apps :
103
- _fa .initialize_app ()
104
- app = _fa .get_app ()
105
99
event_instance = event_attributes ["instance" ]
106
- event_database_host = event_attributes ["firebasedatabasehost" ]
107
- database_reference = _db .reference (
108
- path = event_attributes ["ref" ],
109
- app = app ,
110
- url = f"https://{ event_instance } .{ event_database_host } " ,
111
- )
100
+ event_ref = event_attributes ["ref" ]
112
101
params : dict [str , str ] = {
113
- ** ref_pattern .extract_matches (event_attributes [ "ref" ] ),
102
+ ** ref_pattern .extract_matches (event_ref ),
114
103
** instance_pattern .extract_matches (event_instance ),
115
104
}
116
105
database_event = Event (
117
- firebase_database_host = event_database_host ,
106
+ firebase_database_host = event_attributes [ "firebasedatabasehost" ] ,
118
107
instance = event_instance ,
119
- reference = database_reference ,
108
+ reference = event_ref ,
120
109
location = event_attributes ["location" ],
121
110
specversion = event_attributes ["specversion" ],
122
111
id = event_attributes ["id" ],
0 commit comments