mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 19:34:34 +00:00
16 lines
329 B
TypeScript
16 lines
329 B
TypeScript
import mongoose from 'mongoose'
|
|
import { seedDB } from './seedDB'
|
|
|
|
export const connectDB = async () => {
|
|
try {
|
|
await mongoose.connect(process.env.DB_CONNECT as string)
|
|
} catch (err) {
|
|
throw new Error('Unable to connect to DB!')
|
|
}
|
|
|
|
console.log('Connected to DB!')
|
|
await seedDB()
|
|
|
|
return mongoose.connection
|
|
}
|