19 lines
441 B
JavaScript
19 lines
441 B
JavaScript
|
import mongoose from 'mongoose'
|
||
|
const MONGO_URI =
|
||
|
Bun.env.NODE_ENV === 'development'
|
||
|
? Bun.env.MONGO_DEV_URI
|
||
|
: Bun.env.MONGO_URI
|
||
|
|
||
|
const connectDB = async () => {
|
||
|
mongoose.set('strictQuery', true)
|
||
|
const conn = await mongoose.connect(MONGO_URI)
|
||
|
|
||
|
console.log(
|
||
|
`MongoDB Connected to ${
|
||
|
conn.connection.host
|
||
|
} using ${conn.connection.name.toUpperCase()} database`.cyan.underline.bold
|
||
|
)
|
||
|
}
|
||
|
|
||
|
export default connectDB
|