Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

th1m0
Copy link
Contributor

@th1m0 th1m0 commented Sep 2, 2024

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

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

Copy link

netlify bot commented Sep 2, 2024

👷 Deploy request for n3-supabase pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b756e00

@philliphartin
Copy link

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
Copy link
Contributor Author

th1m0 commented Sep 3, 2024

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 #404

@larbish
Copy link
Collaborator

larbish commented Sep 3, 2024

Thanks 🙏

@larbish larbish merged commit 3f98640 into nuxt-modules:main Sep 3, 2024
1 check passed
@th1m0 th1m0 deleted the fix/server-types branch September 3, 2024 07:47
@Zebnastien
Copy link

Zebnastien commented Oct 11, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants