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
+7
-3
No files matched your search
@@ -16,7 +16,6 @@ export default async function connectDB(uri) {
|
|||||||
return db.connection.getClient()
|
return db.connection.getClient()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
throw new Error('Failed to connect to MongoDB')
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-1
@@ -17,7 +17,12 @@ import expiryRemovalScheduler from './containers/expiryChecker.js'
|
|||||||
import { createTestUser } from './utils/auth.js'
|
import { createTestUser } from './utils/auth.js'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await connectDB(config.db)
|
try {
|
||||||
|
await connectDB(config.db)
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
await createTestUser()
|
await createTestUser()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user