34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
import express from 'express';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import sequelize from './database.js';
|
|
import './models/index.js'; // Stellt sicher, dass die Modelle und Beziehungen geladen werden
|
|
import authRoutes from './routes/authRoutes.js';
|
|
import clubRoutes from './routes/clubRoutes.js'
|
|
import memberRoutes from './routes/memberRoutes.js';
|
|
|
|
const app = express();
|
|
const port = process.env.PORT || 3000;
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
app.use(express.json());
|
|
app.use('/api/auth', authRoutes);
|
|
app.use('/api/clubs', clubRoutes);
|
|
app.use('/api/clubmembers', memberRoutes);
|
|
|
|
app.use(express.static(path.join(__dirname, '../frontend/dist')));
|
|
|
|
app.get('*', (req, res) => {
|
|
res.sendFile(path.join(__dirname, '../frontend/dist/index.html'));
|
|
});
|
|
|
|
sequelize.sync({ alter: true }).then(() => {
|
|
console.log('Database synchronized');
|
|
});
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Server is running on http://localhost:${port}`);
|
|
});
|