parent
3fb493f400
commit
1ce55e4091
2016 changed files with 23595 additions and 15662 deletions
46
lib/database.types.ts
Normal file
46
lib/database.types.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
export type Json =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null
|
||||
| { [key: string]: Json | undefined }
|
||||
| Json[]
|
||||
|
||||
export interface Database {
|
||||
public: {
|
||||
Tables: {
|
||||
todos: {
|
||||
Row: {
|
||||
id: number
|
||||
title: string
|
||||
is_complete: boolean
|
||||
created_at: string
|
||||
updated_at: string | null
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
title: string
|
||||
is_complete?: boolean
|
||||
created_at?: string
|
||||
updated_at?: string | null
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
title?: string
|
||||
is_complete?: boolean
|
||||
created_at?: string
|
||||
updated_at?: string | null
|
||||
}
|
||||
}
|
||||
}
|
||||
Views: {
|
||||
[_ in never]: never
|
||||
}
|
||||
Functions: {
|
||||
[_ in never]: never
|
||||
}
|
||||
Enums: {
|
||||
[_ in never]: never
|
||||
}
|
||||
}
|
||||
}
|
||||
7
lib/supabase.ts
Normal file
7
lib/supabase.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { createClient } from '@supabase/supabase-js'
|
||||
import { Database } from './database.types'
|
||||
|
||||
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL || ''
|
||||
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || ''
|
||||
|
||||
export const supabase = createClient<Database>(supabaseUrl, supabaseKey)
|
||||
35
lib/supabase/server.ts
Normal file
35
lib/supabase/server.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { createServerClient } from '@supabase/ssr'
|
||||
import type { CookieOptions } from '@supabase/ssr'
|
||||
import { cookies } from 'next/headers'
|
||||
import { Database } from '../database.types'
|
||||
|
||||
export function createClient() {
|
||||
return createServerClient<Database>(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||
{
|
||||
cookies: {
|
||||
get(name: string) {
|
||||
return cookies().get(name)?.value
|
||||
},
|
||||
set(name: string, value: string, options: CookieOptions) {
|
||||
cookies().set({
|
||||
name,
|
||||
value,
|
||||
...options,
|
||||
path: options?.path ?? '/',
|
||||
} as any) // Using any temporarily to bypass type checking
|
||||
},
|
||||
remove(name: string, options: CookieOptions) {
|
||||
cookies().set({
|
||||
name,
|
||||
value: '',
|
||||
...options,
|
||||
path: options?.path ?? '/',
|
||||
maxAge: 0,
|
||||
} as any) // Using any temporarily to bypass type checking
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue