const mongoose = require('mongoose');
const config = require('./env');
const logger = require('../utils/logger');

const connectDB = async () => {
  try {
    await mongoose.connect(config.mongoUri, {
      connectTimeoutMS: 30000,
      socketTimeoutMS: 30000
    });
    logger.info('MongoDB verbunden');
  } catch (error) {
    logger.error('MongoDB Verbindungsfehler:', error.message);
    process.exit(1);
  }
};

module.exports = connectDB;
