//config/db.js
const mongoose = require('mongoose');
const connect = async () => {
try {
await mongoose.connect(process.env.MONGODB);
console.log('database connect');
} catch (error) {
console.log(error.message);
}
};
module.exports = connect;
//index.js
require('dotenv').config();
const connect = require('./config/db');
connect();