Skip to content

Commit

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

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

export function useSurrealDatabases() {
export function useSurrealDatabases(): {
[key in DatabasePresetKeys]: DatabasePreset
} {
const {
databases: publicDatabases,
defaultDatabase,
Expand Down
6 changes: 5 additions & 1 deletion src/runtime/server/utils/surreal-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 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 @@ -57,7 +58,10 @@ export function useSurrealDatabases(event?: H3Event): {
return true
})

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

return databases
}
Expand Down

0 comments on commit 451052b

Please sign in to comment.