You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using Nuxt Supabase's serverSupabaseServiceRole role heavily within my app. I use Nuxt's Server API as a layer between my Client and my Supabase DB. So far so good.
import{serverSupabaseServiceRole}from'#supabase/server'exportdefaulteventHandler(async(event)=>{constclient=serverSupabaseServiceRole(event)const{ data }=awaitclient.from('rls-protected-table').select()return{sensitiveData: data}})
Now, as my app logic becomes more complex, I want to migrate some of my logic out of the API route and into the Server Lib folder where I have files of helper functions. The issue is that the only way for those functions to call Supabase is for me to pass either the Client variable or the event from the API route. As an example:
exportdefaulteventHandler(async(event)=>{const{ data }=awaitlibraryFunction('some-id',event)return{someData: data}})
// Example passing Eventimport{serverSupabaseServiceRole}from'#supabase/server'constlibraryFunction=async(id: string,event: any)=>{const{ data }=awaitclient.from('rls-protected-table').select().eq('id',id);return{sensitiveData: data}};export{libraryFunction};
As a simple example, this seems fine but passing the Client/Event around doesn't feel right and will likely get more complex as the app grows. What is the proper way to handle this?
Thanks for the help.
The text was updated successfully, but these errors were encountered:
I've been using Nuxt Supabase's serverSupabaseServiceRole role heavily within my app. I use Nuxt's Server API as a layer between my Client and my Supabase DB. So far so good.
Right now, most of my logic is built right into the API route where I create a 'const client' from serverSupabaseServiceRole from Nitro's event (see this example from https://supabase.nuxtjs.org/usage/services/serversupabaseservicerole)
Now, as my app logic becomes more complex, I want to migrate some of my logic out of the API route and into the Server Lib folder where I have files of helper functions. The issue is that the only way for those functions to call Supabase is for me to pass either the Client variable or the event from the API route. As an example:
As a simple example, this seems fine but passing the Client/Event around doesn't feel right and will likely get more complex as the app grows. What is the proper way to handle this?
Thanks for the help.
The text was updated successfully, but these errors were encountered: