mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
fix: change connect db error handling
This commit is contained in:
1 parent
d3dd12a547
commit
cc9040038d
2 files changed
+6
-2
No files matched your search
@@ -16,7 +16,6 @@ export default async function connectDB(uri) {
|
||||
return db.connection.getClient()
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
return null
|
||||
throw new Error('Failed to connect to MongoDB')
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,12 @@ import expiryRemovalScheduler from './containers/expiryChecker.js'
|
||||
import { createTestUser } from './utils/auth.js'
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
await connectDB(config.db)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
await createTestUser()
|
||||
|
||||
|
||||
Reference in new issue
Block a user