webinterface/server/config/db.js

18 lines
418 B
JavaScript
Raw Permalink Normal View History

2024-10-29 21:09:13 +01:00
const mongoose = require('mongoose');
const dotenv = require('dotenv');
dotenv.config();
// Datenbankverbindung definieren
const connectDB = async () => {
try {
await mongoose.connect(process.env.MONGODB_URI);
console.log('MongoDB connected');
} catch (error) {
console.error('MongoDB connection error:', error.message);
process.exit(1);
}
};
module.exports = connectDB;