@@ -8,20 +8,24 @@ import SupabaseStorage
88
99/// Supabase Client.
1010public class SupabaseClient {
11- private let supabaseURL : URL
12- private let supabaseKey : String
13- private let schema : String
14-
11+ let supabaseURL : URL
12+ let supabaseKey : String
13+ let storageURL : URL
14+ let databaseURL : URL
15+ let realtimeURL : URL
16+ let authURL : URL
1517 let functionsURL : URL
1618
19+ let schema : String
20+
1721 /// Supabase Auth allows you to create and manage user sessions for access to data that is secured
1822 /// by access policies.
1923 public let auth : GoTrueClient
2024
2125 /// Supabase Storage allows you to manage user-generated content, such as photos or videos.
2226 public var storage : SupabaseStorageClient {
2327 SupabaseStorageClient (
24- url: supabaseURL . appendingPathComponent ( " /storage/v1 " ) . absoluteString,
28+ url: storageURL . absoluteString,
2529 headers: defaultHeaders,
2630 http: self
2731 )
@@ -30,7 +34,7 @@ public class SupabaseClient {
3034 /// Database client for Supabase.
3135 public var database : PostgrestClient {
3236 PostgrestClient (
33- url: supabaseURL . appendingPathComponent ( " /rest/v1 " ) ,
37+ url: databaseURL ,
3438 headers: defaultHeaders,
3539 schema: schema,
3640 apiClientDelegate: self
@@ -40,7 +44,7 @@ public class SupabaseClient {
4044 /// Realtime client for Supabase
4145 public var realtime : RealtimeClient {
4246 RealtimeClient (
43- endPoint: supabaseURL . appendingPathComponent ( " /realtime/v1 " ) . absoluteString,
47+ endPoint: realtimeURL . absoluteString,
4448 params: defaultHeaders
4549 )
4650 }
@@ -54,7 +58,7 @@ public class SupabaseClient {
5458 )
5559 }
5660
57- private var defaultHeaders : [ String : String ]
61+ private( set ) var defaultHeaders : [ String : String ]
5862
5963 /// Create a new client.
6064 public init (
@@ -64,6 +68,11 @@ public class SupabaseClient {
6468 ) {
6569 self . supabaseURL = supabaseURL
6670 self . supabaseKey = supabaseKey
71+ authURL = supabaseURL. appendingPathComponent ( " /auth/v1 " )
72+ storageURL = supabaseURL. appendingPathComponent ( " /storage/v1 " )
73+ databaseURL = supabaseURL. appendingPathComponent ( " /rest/v1 " )
74+ realtimeURL = supabaseURL. appendingPathComponent ( " /realtime/v1 " )
75+
6776 schema = options. db. schema
6877 httpClient = options. global. httpClient
6978
@@ -73,7 +82,7 @@ public class SupabaseClient {
7382 ] . merging ( options. global. headers) { _, new in new }
7483
7584 auth = GoTrueClient (
76- url: supabaseURL . appendingPathComponent ( " /auth/v1 " ) ,
85+ url: authURL ,
7786 headers: defaultHeaders,
7887 localStorage: options. auth. storage
7988 )
0 commit comments