Initial commit
This commit is contained in:
14
backend/config/db.js
Normal file
14
backend/config/db.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
const connectDb = async () => {
|
||||
const mongoUri = process.env.MONGODB_URI;
|
||||
if (!mongoUri) {
|
||||
throw new Error("MONGODB_URI is not set");
|
||||
}
|
||||
|
||||
mongoose.set("strictQuery", true);
|
||||
await mongoose.connect(mongoUri);
|
||||
return mongoose.connection;
|
||||
};
|
||||
|
||||
module.exports = connectDb;
|
||||
Reference in New Issue
Block a user