refactor: generate and use Supabase TypeScript types
Co-authored-by: Moheeb Zara <[email protected]>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
import type { Database } from '@/types/database'
|
||||
|
||||
/**
|
||||
* Admin client using the service role key.
|
||||
@@ -6,7 +7,7 @@ import { createClient } from '@supabase/supabase-js'
|
||||
* NEVER expose this client to the browser.
|
||||
*/
|
||||
export function createAdminClient() {
|
||||
return createClient(
|
||||
return createClient<Database>(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.SUPABASE_SERVICE_ROLE_KEY!,
|
||||
{
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { createBrowserClient } from '@supabase/ssr'
|
||||
import type { Database } from '@/types/database'
|
||||
|
||||
export function createClient() {
|
||||
return createBrowserClient(
|
||||
return createBrowserClient<Database>(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createServerClient } from '@supabase/ssr'
|
||||
import { cookies } from 'next/headers'
|
||||
import type { Database } from '@/types/database'
|
||||
|
||||
/**
|
||||
* Especially important if using Fluid compute: Don't put this client in a
|
||||
@@ -9,7 +10,7 @@ import { cookies } from 'next/headers'
|
||||
export async function createClient() {
|
||||
const cookieStore = await cookies()
|
||||
|
||||
return createServerClient(
|
||||
return createServerClient<Database>(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user