Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b46fc37

Browse files
committed
fix(nuxthub): ensure database is enabled
1 parent ad45699 commit b46fc37

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ export default defineNuxtModule<ModuleOptions>({
160160
}
161161

162162
// Load nitro preset and set db adapter
163+
const preset = findPreset(nuxt)
164+
await preset?.setup?.(options, nuxt)
163165
nuxt.hook('nitro:config', async (config) => {
164166
const preset = findPreset(nuxt)
165167
await preset.setupNitro(config, { manifest, resolver, moduleOptions: options })

src/presets/nuxthub.ts

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import cfPreset from './cloudflare-pages'
55

66
export default definePreset({
77
name: 'nuxthub',
8+
async setup(options, nuxt) {
9+
// Make sure database is enabled
10+
const nuxthubOptions: { database?: boolean } = (nuxt.options as unknown as { hub: unknown }).hub ||= {}
11+
nuxthubOptions.database = true
12+
},
813
async setupNitro(nitroConfig, options) {
914
await cfPreset.setupNitro(nitroConfig, options)
1015

src/utils/preset.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { NitroConfig } from 'nitropack'
22
import type { Resolver } from '@nuxt/kit'
3+
import type { Nuxt } from '@nuxt/schema'
34
import type { ModuleOptions } from '../types/module'
45
import type { Manifest } from '../types/manifest'
56

@@ -10,6 +11,7 @@ interface Options {
1011
}
1112
export interface Preset {
1213
name: string
14+
setup?: (options: ModuleOptions, nuxt: Nuxt) => Promise<void>
1315
setupNitro: (nitroConfig: NitroConfig, opts: Options) => void | Promise<void>
1416
}
1517

0 commit comments

Comments
 (0)