nuxt-modules / supabase

Supabase module for Nuxt.
https://supabase.nuxtjs.org
MIT License
733 stars 129 forks source link

fix(types): added explicit types annotations for `serverSupabaseClient` and `serverSupabaseServiceRole` #411

Closed th1m0 closed 2 months ago

th1m0 commented 2 months ago

Types of changes

Description

Added explicit type annotations for serverSupabaseClient and serverSupabaseServiceRole as they lose the Database type when building.

netlify[bot] commented 2 months ago

Deploy request for n3-supabase pending review.

Visit the deploys page to approve it

Name Link
Latest commit b756e00331b0ca4b8cc72c5d8c37ee083ac6dcc1
philliphartin commented 2 months ago

With this addition, is there a simple way to use the Database types generated by the Supabase CLI? https://supabase.com/docs/guides/api/rest/generating-types

th1m0 commented 2 months ago

With this addition, is there a simple way to use the Database types generated by the Supabase CLI? supabase.com/docs/guides/api/rest/generating-types

Yes you should no longer be needed to pass in the Database types in the functions serverSupabaseClient and serverSupabaseServiceRole

This should work fine:

import { serverSupabaseClient } from '#supabase/server'

export default defineEventHandler(async (event) => {
    const client = await serverSupabaseClient(event)
})

client should have the types generated by the supabase cli automatically if you set the types path correctly in nuxt.config.ts

This was also done for the composables in https://github.com/nuxt-modules/supabase/pull/404

larbish commented 2 months ago

Thanks 🙏

Zebnastien commented 1 month ago

client should have the types generated by the supabase cli automatically if you set the types path correctly in nuxt.config.ts

@th1m0, the documentation states that the default path is "./types/database.types.ts," however, I had to specify it explicitly in nuxt.config.ts for it to work.

Thanks you both for the work <3

th1m0 commented 1 month ago

@Zebnastien Thanks for reaching out! That would be a bug, could you please raise an issue about this?

Zebnastien commented 1 month ago

@th1m0 Done. Thanks!