File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
import mongoose from 'mongoose'
2
2
import type { DevtoolsServerContext , ServerFunctions } from '../types'
3
+ import { logger } from '@nuxt/kit'
3
4
4
5
import { setupDatabaseRPC } from './database'
5
6
import { setupResourceRPC } from './resource'
6
7
7
8
export function setupRPC ( ctx : DevtoolsServerContext ) : ServerFunctions {
8
- mongoose . connect ( ctx . options . uri , ctx . options . options )
9
+ if ( ! ctx . options . uri ) {
10
+ ctx . options . uri = ''
11
+ logger . warn ( 'MongoDB autoconnect is disabled, configure `uri` to enable.' )
12
+ } else {
13
+ mongoose . connect ( ctx . options . uri , ctx . options . options )
14
+ }
9
15
10
16
return {
11
17
getOptions ( ) {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { useRuntimeConfig } from '#imports'
9
9
export async function defineMongooseConnection ( { uri, options } : { uri ?: string ; options ?: ConnectOptions } = { } ) : Promise < void > {
10
10
const config = useRuntimeConfig ( ) . mongoose
11
11
const mongooseUri = uri || config . uri
12
+ if ( ! ( mongooseUri as string ) . trim ( ) ) return
12
13
const mongooseOptions = options || config . options
13
14
14
15
try {
You can’t perform that action at this time.
0 commit comments