Effect CommunityEC
Effect Community2y ago
3 replies
nickrttn

Creating a Supabase client and injecting arguments using Layer

Hey folks,

I'm trying to create a Supabase client using const supabase = createServerSupabaseClient<Database>({ req, res });. I want to use Layer to inject it into my effect context. However, how do I provide the arguments to the Layer when I create it? For a different instance of Supabase, I'm using this:
export const SupabaseAdminLive = Layer.sync(SupabaseAdminTag, () =>
  createServiceRoleSupabaseClient(),
);

and I was hoping I could inject arguments via that callback somehow, eg. something like this:
export const SupabaseServerLive = Layer.sync(
  SupabaseServerTag,
  (req: NextApiRequest, res: NextApiResponse) => createServerSupabaseClient(req, res),
);
, but I haven't been able to figure out how to do that
Was this page helpful?