@@ -8,20 +8,24 @@ import SupabaseStorage
8
8
9
9
/// Supabase Client.
10
10
public 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
15
17
let functionsURL : URL
16
18
19
+ let schema : String
20
+
17
21
/// Supabase Auth allows you to create and manage user sessions for access to data that is secured
18
22
/// by access policies.
19
23
public let auth : GoTrueClient
20
24
21
25
/// Supabase Storage allows you to manage user-generated content, such as photos or videos.
22
26
public var storage : SupabaseStorageClient {
23
27
SupabaseStorageClient (
24
- url: supabaseURL . appendingPathComponent ( " /storage/v1 " ) . absoluteString,
28
+ url: storageURL . absoluteString,
25
29
headers: defaultHeaders,
26
30
http: self
27
31
)
@@ -30,7 +34,7 @@ public class SupabaseClient {
30
34
/// Database client for Supabase.
31
35
public var database : PostgrestClient {
32
36
PostgrestClient (
33
- url: supabaseURL . appendingPathComponent ( " /rest/v1 " ) ,
37
+ url: databaseURL ,
34
38
headers: defaultHeaders,
35
39
schema: schema,
36
40
apiClientDelegate: self
@@ -40,7 +44,7 @@ public class SupabaseClient {
40
44
/// Realtime client for Supabase
41
45
public var realtime : RealtimeClient {
42
46
RealtimeClient (
43
- endPoint: supabaseURL . appendingPathComponent ( " /realtime/v1 " ) . absoluteString,
47
+ endPoint: realtimeURL . absoluteString,
44
48
params: defaultHeaders
45
49
)
46
50
}
@@ -54,7 +58,7 @@ public class SupabaseClient {
54
58
)
55
59
}
56
60
57
- private var defaultHeaders : [ String : String ]
61
+ private( set ) var defaultHeaders : [ String : String ]
58
62
59
63
/// Create a new client.
60
64
public init (
@@ -64,6 +68,11 @@ public class SupabaseClient {
64
68
) {
65
69
self . supabaseURL = supabaseURL
66
70
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
+
67
76
schema = options. db. schema
68
77
httpClient = options. global. httpClient
69
78
@@ -73,7 +82,7 @@ public class SupabaseClient {
73
82
] . merging ( options. global. headers) { _, new in new }
74
83
75
84
auth = GoTrueClient (
76
- url: supabaseURL . appendingPathComponent ( " /auth/v1 " ) ,
85
+ url: authURL ,
77
86
headers: defaultHeaders,
78
87
localStorage: options. auth. storage
79
88
)
0 commit comments