Some checks failed
🚀 Continuous Integration / 🔧 Backend Tests (18.x) (push) Has been cancelled
🚀 Continuous Integration / 🔧 Backend Tests (20.x) (push) Has been cancelled
🚀 Continuous Integration / 🎨 Frontend Tests (18.x) (push) Has been cancelled
🚀 Continuous Integration / 🎨 Frontend Tests (20.x) (push) Has been cancelled
🚀 Continuous Integration / 🔍 Code Quality (push) Has been cancelled
🚀 Continuous Integration / 🔒 Security Checks (push) Has been cancelled
🚀 Continuous Integration / 🎨 Theme Tests (push) Has been cancelled
🚀 Continuous Integration / ♿ Accessibility Tests (push) Has been cancelled
🚀 Continuous Integration / 📱 Cross-Browser Tests (push) Has been cancelled
🚀 Continuous Integration / 🏗️ Build Tests (push) Has been cancelled
🚀 Continuous Integration / 📊 Performance Tests (push) Has been cancelled
🚀 Continuous Integration / 🎯 Integration Tests (push) Has been cancelled
🚀 Continuous Integration / ✅ All Tests Passed (push) Has been cancelled
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
const express = require('express');
|
|
const mongoose = require('mongoose');
|
|
const cors = require('cors');
|
|
const path = require('path');
|
|
require('dotenv').config();
|
|
|
|
const app = express();
|
|
|
|
// Middleware
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
|
|
// MongoDB Verbindung
|
|
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/familien-held';
|
|
|
|
mongoose.connect(MONGODB_URI, {
|
|
useNewUrlParser: true,
|
|
useUnifiedTopology: true,
|
|
})
|
|
.then(() => console.log('✅ MongoDB verbunden'))
|
|
.catch(err => console.error('❌ MongoDB Verbindungsfehler:', err));
|
|
|
|
// API Routes
|
|
app.use('/api/auth', require('./routes/auth'));
|
|
app.use('/api/child-auth', require('./routes/childAuth'));
|
|
app.use('/api/families', require('./routes/families'));
|
|
app.use('/api/children', require('./routes/children'));
|
|
app.use('/api/tasks', require('./routes/tasks'));
|
|
app.use('/api/rewards', require('./routes/rewards'));
|
|
app.use('/api/public', require('./routes/public'));
|
|
|
|
// Serve static files from React app in production
|
|
if (process.env.NODE_ENV === 'production') {
|
|
app.use(express.static(path.join(__dirname, 'client/build')));
|
|
|
|
app.get('*', (req, res) => {
|
|
res.sendFile(path.join(__dirname, 'client/build', 'index.html'));
|
|
});
|
|
}
|
|
|
|
// Basis Route für Entwicklung
|
|
app.get('/', (req, res) => {
|
|
res.json({
|
|
message: '🎉 Familien-Held API läuft!',
|
|
version: '1.0.0',
|
|
endpoints: [
|
|
'/api/auth - Eltern-Authentifizierung',
|
|
'/api/child-auth - Kinder-Authentifizierung',
|
|
'/api/families - Familien-Management',
|
|
'/api/children - Kinder-Profile',
|
|
'/api/tasks - Aufgaben-Verwaltung',
|
|
'/api/rewards - Belohnungs-System'
|
|
]
|
|
});
|
|
});
|
|
|
|
const PORT = process.env.PORT || 5000;
|
|
app.listen(PORT, () => {
|
|
console.log(`🚀 Server läuft auf Port ${PORT}`);
|
|
console.log(`📱 Familien-Held API bereit!`);
|
|
});
|
|
|
|
module.exports = app; |