Skip to content

Commit

Permalink
fix: database presets merge types
Browse files Browse the repository at this point in the history
  • Loading branch information
sandros94 committed Jul 11, 2024
1 parent 17ed7b2 commit 2630b6b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export default defineNuxtModule<ModuleOptions>({
ws: '',
NS: '',
DB: '',
KV: undefined,
SC: undefined,
AC: undefined,
auth: undefined,
},
},
server: {
Expand Down
5 changes: 1 addition & 4 deletions src/runtime/composables/surreal-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { hash } from 'ohash'
import { createDefu, defu } from 'defu'

import type {
DatabasePreset,
DatabasePresetKeys,
KeysOf,
PickFrom,
Expand Down Expand Up @@ -97,9 +96,7 @@ export function useSurrealRPC<
})
}

export function useSurrealDatabases(): {
[key in DatabasePresetKeys]: DatabasePreset
} {
export function useSurrealDatabases() {
const {
databases: publicDatabases,
defaultDatabase,
Expand Down
6 changes: 1 addition & 5 deletions src/runtime/server/utils/surreal-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// The following nitropack import is from https://github.com/nuxt/module-builder/issues/141#issuecomment-2078248248
import type {} from 'nitropack'
import type { PublicRuntimeConfig, RuntimeConfig } from 'nuxt/schema'
import type { FetchOptions, ResponseType } from 'ofetch'
import { textToBase64 } from 'undio'
import type { H3Event } from 'h3'
Expand Down Expand Up @@ -58,10 +57,7 @@ export function useSurrealDatabases(event?: H3Event): {
return true
})

const databases = defuDatabases<
RuntimeConfig['surrealdb']['databases'],
PublicRuntimeConfig['surrealdb']['databases'][]
>(privateDatabases, publicDatabases)
const databases = defuDatabases(privateDatabases, publicDatabases)

return databases
}
Expand Down

0 comments on commit 2630b6b

Please sign in to comment.