Dicken Dock v1.0.0
This commit is contained in:
34
backend/src/index.js
Normal file
34
backend/src/index.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
require('./db'); // Datenbank + Tabellen initialisieren
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
|
||||
// ── Core-Routen ───────────────────────────────────────────────────────────────
|
||||
app.use('/api/auth', require('./routes/auth'));
|
||||
app.use('/api/admin', require('./routes/admin'));
|
||||
app.use('/api/dashboard', require('./routes/dashboard'));
|
||||
app.use('/api/system', require('./routes/system'));
|
||||
|
||||
// ── Tool-Routen automatisch laden ─────────────────────────────────────────────
|
||||
// Neues Tool: Datei unter src/tools/<name>/routes.js ablegen → wird automatisch eingebunden
|
||||
const toolsDir = path.join(__dirname, 'tools');
|
||||
fs.readdirSync(toolsDir, { withFileTypes: true })
|
||||
.filter(d => d.isDirectory())
|
||||
.forEach(d => {
|
||||
const routeFile = path.join(toolsDir, d.name, 'routes.js');
|
||||
if (fs.existsSync(routeFile)) {
|
||||
app.use(`/api/tools/${d.name}`, require(routeFile));
|
||||
console.log(` 🔧 Tool geladen: ${d.name}`);
|
||||
}
|
||||
});
|
||||
|
||||
// ── React-Frontend ausliefern ─────────────────────────────────────────────────
|
||||
const PUBLIC = path.join(__dirname, '../public');
|
||||
app.use(express.static(PUBLIC));
|
||||
app.get('*', (_req, res) => res.sendFile(path.join(PUBLIC, 'index.html')));
|
||||
|
||||
app.listen(4000, () => console.log('🚀 Dicken Dock läuft auf Port 4000'));
|
||||
Reference in New Issue
Block a user