18 lines
418 B
JavaScript
18 lines
418 B
JavaScript
|
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;
|