Elixir library for interfacing with Firebase.
The package can be installed by adding firebase to your list of dependencies in mix.exs:
def deps do
[
{:firebase, "~> 0.1.0"}
]
endAdd Firebase settings to config/runtime.exs:
config :firebase,
project_id: System.get_env("FIREBASE_PROJECT_ID"),
auth_emulator_host: System.get_env("FIREBASE_AUTH_EMULATOR_HOST")By default, public keys are fetched from Google's public endpoint. For testing purposes, set the mock Firebase key source in config/test.exs:
config :firebase,
key_source: Firebase.Auth.KeySource.MockEnsure the key cache GenServer is being supervised:
def start(_type, _args) do
children = [
...
{Firebase.Auth.KeyCache, []}
]
endOptionally, to automatically manage the Firebase emulator GenServer, make the following changes in application.ex:
def start(_type, _args) do
children = [
...
] ++ dev_children() # Add this function call
end
# Define a private function
defp dev_children() do
if Application.get_env(:my_app, :dev_routes, false) and
Phoenix.Endpoint.server?(:my_app, MyAppWeb.Endpoint) do
[{Firebase.Emulator, []}]
else
[]
end
end