Files
MERN_STACK_TEMPLATE/backend/db/connectDB.js
Dongho Kim 7333cf79bd
All checks were successful
gitea/MERN_STACK_TEMPLATE/pipeline/head This commit looks good
added to routes for the user auth
2025-05-02 13:24:52 +02:00

11 lines
340 B
JavaScript

import mongoose from "mongoose";
export const connectDB = async () => {
try {
const conn = await mongoose.connect(process.env.MONGO_URI);
console.log(`MongoDB Connected: ${conn.connection.host}`);
} catch(error) {
console.log("Error connection to MongoDB: ", error.message);
process.exit(1);
}
}