fix: resolve build stuck issue with nitro pre-render enabled (#26)

This commit is contained in:
Arash
2023-10-04 04:56:15 +03:00
committed by GitHub
parent e7c7beb8fd
commit c570597d06

View File

@ -8,6 +8,7 @@ import {
import type { ConnectOptions } from 'mongoose' import type { ConnectOptions } from 'mongoose'
import defu from 'defu' import defu from 'defu'
import { join } from 'pathe' import { join } from 'pathe'
import mongoose from 'mongoose'
import { $fetch } from 'ofetch' import { $fetch } from 'ofetch'
import { version } from '../package.json' import { version } from '../package.json'
import { setupDevToolsUI } from './devtools' import { setupDevToolsUI } from './devtools'
@ -54,6 +55,11 @@ export default defineNuxtModule<ModuleOptions>({
options: {}, options: {},
modelsDir: 'models', modelsDir: 'models',
}, },
hooks: {
close: () => {
mongoose.disconnect()
},
},
async setup(options, nuxt) { async setup(options, nuxt) {
if (nuxt.options.dev) { if (nuxt.options.dev) {
$fetch('https://registry.npmjs.org/nuxt-mongoose/latest').then((release) => { $fetch('https://registry.npmjs.org/nuxt-mongoose/latest').then((release) => {