Skip to content
Snippets Groups Projects
Commit 7b13998a authored by Jesus Galaz's avatar Jesus Galaz
Browse files

Wrong version of this file, fixed with this commit

parent 1cb210ae
No related branches found
No related tags found
1 merge request!5User authentication implemented
const mongoose = require('mongoose');
require('dotenv').config();
// Function to connect to MongoDB using Mongoose and create collections
async function connectDB() {
const connectDB = async () => {
try {
// Connect using the MongoDB URI from environment variables
const conn = await mongoose.connect(process.env.MONGO_URI || "mongodb://127.0.0.1:27017/todo_app");
const conn = await mongoose.connect(process.env.MONGO_URI);
console.log(`MongoDB connected: ${conn.connection.host}`);
} catch (err) {
console.error(`Error: ${err.message}`);
process.exit(1); // Exit the process with failure if the connection fails
process.exit(1);
}
}
};
module.exports = connectDB;
\ No newline at end of file
module.exports = connectDB;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment