Skip to content

torcera/ex_firebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Firebase

Elixir library for interfacing with Firebase.

Installation

The package can be installed by adding firebase to your list of dependencies in mix.exs:

def deps do
  [
    {:firebase, "~> 0.1.0"}
  ]
end

Add 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.Mock

Ensure the key cache GenServer is being supervised:

def start(_type, _args) do
  children = [
    ...
    {Firebase.Auth.KeyCache, []}
  ]
end

Firebase Emulator

Optionally, 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

About

Elixir library for interfacing with Firebase.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published