Skip to content

Commit

Permalink
fix: server-side type import
Browse files Browse the repository at this point in the history
  • Loading branch information
th1m0 committed Sep 2, 2024
1 parent 2f1f652 commit b756e00
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export default defineNuxtModule<ModuleOptions>({
inline: [resolve('./runtime')],
})
nitroConfig.alias['#supabase/server'] = resolveRuntimeModule('./server/services')
nitroConfig.alias['#supabase/database'] = resolve(nitroConfig.buildDir!, 'types/supabase-database')
})

addTemplate({
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/server/services/serverSupabaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { createServerClient, parseCookieHeader, type CookieOptions } from '@supa
import { getHeader, setCookie, type H3Event } from 'h3'
import { fetchWithRetry } from '../../utils/fetch-retry'
import { useRuntimeConfig } from '#imports'
import type { Database } from '#build/types/supabase-database'
// @ts-expect-error - `#supabase/database` is a runtime alias
import type { Database } from '#supabase/database'

export const serverSupabaseClient: <T = Database>(event: H3Event) => Promise<SupabaseClient<T>> = async <T = Database>(event: H3Event) => {
// No need to recreate client if exists in request context
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/server/services/serverSupabaseServiceRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { SupabaseClient } from '@supabase/supabase-js'
import { createClient } from '@supabase/supabase-js'
import type { H3Event } from 'h3'
import { useRuntimeConfig } from '#imports'
import type { Database } from '#build/types/supabase-database'
// @ts-expect-error - `#supabase/database` is a runtime alias
import type { Database } from '#supabase/database'

export const serverSupabaseServiceRole: <T = Database>(event: H3Event) => SupabaseClient<T> = <T = Database>(event: H3Event) => {
const {
Expand Down

0 comments on commit b756e00

Please sign in to comment.