Skip to content

Commit eea0444

Browse files
committed
feat: bump storage version, and expose StorageClientOptions
1 parent 137caec commit eea0444

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/SupabaseClient.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ export default class SupabaseClient<
4242
*/
4343
auth: SupabaseAuthClient
4444
realtime: RealtimeClient
45+
/**
46+
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
47+
*/
48+
storage: SupabaseStorageClient
4549

4650
protected realtimeUrl: URL
4751
protected authUrl: URL
@@ -64,6 +68,7 @@ export default class SupabaseClient<
6468
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
6569
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
6670
* @param options.realtime Options passed along to realtime-js constructor.
71+
* @param options.storage Options passed along to the storage-js constructor.
6772
* @param options.global.fetch A custom fetch implementation.
6873
* @param options.global.headers Any additional headers to send with each network request.
6974
*/
@@ -130,6 +135,13 @@ export default class SupabaseClient<
130135
fetch: this.fetch,
131136
})
132137

138+
this.storage = new SupabaseStorageClient(
139+
this.storageUrl.href,
140+
this.headers,
141+
this.fetch,
142+
options?.storage
143+
)
144+
133145
if (!settings.accessToken) {
134146
this._listenForAuthEvents()
135147
}
@@ -145,13 +157,6 @@ export default class SupabaseClient<
145157
})
146158
}
147159

148-
/**
149-
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
150-
*/
151-
get storage(): SupabaseStorageClient {
152-
return new SupabaseStorageClient(this.storageUrl.href, this.headers, this.fetch)
153-
}
154-
155160
// NOTE: signatures must be kept in sync with PostgrestClient.from
156161
from<
157162
TableName extends string & keyof Schema['Tables'],

src/lib/helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function applySettingDefaults<
5050
...DEFAULT_REALTIME_OPTIONS,
5151
...realtimeOptions,
5252
},
53+
storage: {},
5354
global: {
5455
...DEFAULT_GLOBAL_OPTIONS,
5556
...globalOptions,

src/lib/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { AuthClient } from '@supabase/auth-js'
22
import { RealtimeClientOptions } from '@supabase/realtime-js'
33
import { PostgrestError } from '@supabase/postgrest-js'
4+
import { StorageClientOptions } from '@supabase/storage-js/dist/module/StorageClient'
45

56
type AuthClientOptions = ConstructorParameters<typeof AuthClient>[0]
67

@@ -56,6 +57,7 @@ export type SupabaseClientOptions<SchemaName> = {
5657
* Options passed to the realtime-js instance
5758
*/
5859
realtime?: RealtimeClientOptions
60+
storage?: StorageClientOptions
5961
global?: {
6062
/**
6163
* A custom `fetch` implementation.

0 commit comments

Comments
 (0)