1
- import type { CookieOptions } from " @supabase/ssr" ;
2
- import { createServerClient } from " @supabase/ssr" ;
1
+ import type { CookieOptions } from ' @supabase/ssr' ;
2
+ import { createServerClient } from ' @supabase/ssr' ;
3
3
4
- import type { CookieStore , Database } from " ./types" ;
4
+ import type { CookieStore , Database } from ' ./types' ;
5
5
6
6
interface BaseOptions {
7
7
supabaseApiUrl : string ;
@@ -14,34 +14,30 @@ interface BaseOptions {
14
14
}
15
15
16
16
export function createClient ( configOptions : BaseOptions ) {
17
- return createServerClient < Database > (
18
- configOptions . supabaseApiUrl ,
19
- configOptions . supabaseKey ,
20
- {
21
- cookies : {
22
- get ( name : string ) {
23
- return configOptions . cookieStore ?. get ( name ) ?. value ;
24
- } ,
25
- set ( name : string , value : string , options : CookieOptions ) {
26
- try {
27
- configOptions . cookieStore ?. set ( { name, value, ...options } ) ;
28
- } catch ( error ) {
29
- // The `set` method was called from a Server Component.
30
- // This can be ignored if you have middleware refreshing
31
- // user sessions.
32
- }
33
- } ,
34
- remove ( name : string , options : CookieOptions ) {
35
- try {
36
- configOptions . cookieStore ?. set ( { name, value : "" , ...options } ) ;
37
- } catch ( error ) {
38
- // The `set` method was called from a Server Component.
39
- // The `delete` method was called from a Server Component.
40
- // This can be ignored if you have middleware refreshing
41
- // user sessions.
42
- }
43
- } ,
17
+ return createServerClient < Database > ( configOptions . supabaseApiUrl , configOptions . supabaseKey , {
18
+ cookies : {
19
+ get ( name : string ) {
20
+ return configOptions . cookieStore ?. get ( name ) ?. value ;
21
+ } ,
22
+ set ( name : string , value : string , options : CookieOptions ) {
23
+ try {
24
+ configOptions . cookieStore ?. set ( { name, value, ...options } ) ;
25
+ } catch ( error ) {
26
+ // The `set` method was called from a Server Component.
27
+ // This can be ignored if you have middleware refreshing
28
+ // user sessions.
29
+ }
30
+ } ,
31
+ remove ( name : string , options : CookieOptions ) {
32
+ try {
33
+ configOptions . cookieStore ?. set ( { name, value : '' , ...options } ) ;
34
+ } catch ( error ) {
35
+ // The `set` method was called from a Server Component.
36
+ // The `delete` method was called from a Server Component.
37
+ // This can be ignored if you have middleware refreshing
38
+ // user sessions.
39
+ }
44
40
} ,
45
41
} ,
46
- ) ;
42
+ } ) ;
47
43
}
0 commit comments