Skip to content

Commit 0c94303

Browse files
authored
fix: fetch json_library option on compile-time (#74)
1 parent 00088a4 commit 0c94303

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

config/config.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ if config_env() == :dev do
55
base_url: System.fetch_env!("SUPABASE_URL"),
66
api_key: System.fetch_env!("SUPABASE_KEY"),
77
env: config_env()
8+
9+
config :supabase, json_library: JSON
810
end

lib/supabase.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ defmodule Supabase do
166166
apply(__MODULE__, which, [])
167167
end
168168

169+
@json_library Application.compile_env(:supabase, :json_library, Jason)
170+
169171
@doc "Returns the configured JSON encoding library for Supabase libraries."
170-
def json_library do
171-
Application.get_env(:supabase, :json_library, Jason)
172-
end
172+
def json_library, do: @json_library
173173
end

lib/supabase/fetcher/body_decoder.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ defmodule Supabase.Fetcher.JSONDecoder do
3333

3434
@doc "Tries to decode the response body as JSON"
3535
@impl true
36-
def decode(%Response{body: body}, opts \\ []) do
37-
keys = Keyword.get(opts, :keys, :strings)
38-
Supabase.json_library().decode(body, keys: keys)
36+
def decode(%Response{body: body}, _) do
37+
Supabase.json_library().decode(body)
3938
end
4039
end

0 commit comments

Comments
 (0)