aboutsummaryrefslogtreecommitdiffstats
path: root/server/config
diff options
context:
space:
mode:
Diffstat (limited to 'server/config')
-rw-r--r--server/config/db.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/server/config/db.js b/server/config/db.js
new file mode 100644
index 0000000..effbe5e
--- /dev/null
+++ b/server/config/db.js
@@ -0,0 +1,14 @@
+const mongoose = require('mongoose')
+const connecttDB = async () => {
+ try {
+ await mongoose.connect(process.env.MONGO_URI, {
+ useNewUrlParser: true,
+ useUnifiedTopology: true,
+ });
+ console.log('MongoDB Connected...');
+ } catch (err) {
+ console.error(err.message);
+ process.exit(1);
+ }
+};
+module.exports = connectDB;