webinterface/server/app.js

33 lines
715 B
JavaScript

require('dotenv').config(); // Muss ganz oben stehen
const mongoose = require('mongoose');
const express = require('express');
const cors = require('cors');
const dotenv = require('dotenv');
const connectDB = require('./config/db');
const authRoutes = require('./routes/authRoutes');
dotenv.config();
// Verbindung zur Datenbank aufbauen
connectDB();
const app = express();
// Middleware
app.use(cors());
app.use(express.json());
// Authentifizierungsrouten
app.use('/api/auth', authRoutes);
// Beispiel-Route
app.get('/', (req, res) => {
res.send('API läuft');
});
// Server starten
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server läuft auf Port ${PORT}`);
});