mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
- Remove unnecessary try-catch block in createSession function - Add error handling for missing session ID in socket.js - Improve error handling in connectDB function - Add error handling middleware for server errors - Add default export for get function in env.js Signed-off-by: wancat <wancat@wancat.cc>
13 lines
263 B
JavaScript
13 lines
263 B
JavaScript
import mongoose from 'mongoose'
|
|
import config from './config.js'
|
|
|
|
export default async function connectDB() {
|
|
try {
|
|
await mongoose.connect(config.db)
|
|
console.log('Connected to MongoDB')
|
|
} catch (err) {
|
|
console.error(err)
|
|
process.exit(1)
|
|
}
|
|
}
|