Skip to content

Latest commit

 

History

History
70 lines (55 loc) · 1.41 KB

README.md

File metadata and controls

70 lines (55 loc) · 1.41 KB

Clerk

HTTP client for the ClerkJS sdk. https://clerk.com/docs/reference/backend-api

Installation

If available in Hex, the package can be installed by adding clerk to your list of dependencies in mix.exs:

def deps do
  [
    {:clerk, "~> 1.0.1"}
  ]
end

Once the dependency is installed you can add your clerk domain to the config, the clerk module to the application tree, and then you can make API calls.

in the config

  config :clerk,
    domain: "example.clerk.accounts.dev"

In you application's supervisor:

  children = [
    ...
    {Clerk, Application.get_all_env(:clerk)},
    ...
  ]

and then

  iex> Clerk.User.list()
  {:ok,
    [
      %{
        "id" => "user_abcd12345",
        "locked" => false,
        "has_image" => true,
        "banned" => false,
        ...
      }
    ]
  }

You can also use the Clerk.AuthenticationPlug to automatically load the clerk session and user in plug based elixir applications. i.e. (in phoenix):

  pipeline :api do
    plug :accepts, ["json"]
    plug :fetch_session
    plug Clerk.AuthenticationPlug
  end

will place a current_user object in conn.assigns

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/clerk.