mirror of
https://github.com/supabase/supabase.git
synced 2026-07-06 16:44:19 +08:00
25 lines
574 B
TypeScript
25 lines
574 B
TypeScript
import type { User } from '@supabase/supabase-js'
|
|
import * as configcat from 'configcat-js'
|
|
|
|
let client: configcat.IConfigCatClient
|
|
|
|
function getClient() {
|
|
if (client) {
|
|
return client
|
|
}
|
|
|
|
client = configcat.getClient(
|
|
process.env.NEXT_PUBLIC_CONFIGCAT_SDK_KEY ?? '',
|
|
configcat.PollingMode.AutoPoll,
|
|
{ pollIntervalSeconds: 600 }
|
|
)
|
|
|
|
return client
|
|
}
|
|
|
|
export async function getFlags(user?: User) {
|
|
return user?.email !== undefined
|
|
? await getClient().getAllValuesAsync(new configcat.User(user.email))
|
|
: await getClient().getAllValuesAsync()
|
|
}
|