Dateien nach "backend/src" hochladen
This commit is contained in:
@@ -2,19 +2,18 @@ const express = require('express');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
require('./db'); // Datenbank + Tabellen initialisieren
|
||||
require('./db');
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
|
||||
// ── Core-Routen ───────────────────────────────────────────────────────────────
|
||||
// ── API ───────────────────────────────────────────────────────────────────────
|
||||
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
|
||||
// Tool-Routen automatisch laden
|
||||
const toolsDir = path.join(__dirname, 'tools');
|
||||
fs.readdirSync(toolsDir, { withFileTypes: true })
|
||||
.filter(d => d.isDirectory())
|
||||
@@ -26,16 +25,19 @@ fs.readdirSync(toolsDir, { withFileTypes: true })
|
||||
}
|
||||
});
|
||||
|
||||
// ── React-Frontend ausliefern ─────────────────────────────────────────────────
|
||||
// ── Frontend ──────────────────────────────────────────────────────────────────
|
||||
const PUBLIC = path.join(__dirname, '../public');
|
||||
|
||||
// Service Worker braucht diesen Header damit er auf '/' zugreifen darf
|
||||
app.use((req, res, next) => {
|
||||
if (req.path === '/sw.js') {
|
||||
res.setHeader('Service-Worker-Allowed', '/');
|
||||
res.setHeader('Cache-Control', 'no-cache');
|
||||
}
|
||||
next();
|
||||
app.get('/manifest.json', (_req, res) => {
|
||||
res.setHeader('Content-Type', 'application/manifest+json');
|
||||
res.setHeader('Cache-Control', 'no-cache');
|
||||
res.sendFile(path.join(PUBLIC, 'manifest.json'));
|
||||
});
|
||||
app.get('/sw.js', (_req, res) => {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
res.setHeader('Service-Worker-Allowed', '/');
|
||||
res.setHeader('Cache-Control', 'no-cache');
|
||||
res.sendFile(path.join(PUBLIC, 'sw.js'));
|
||||
});
|
||||
|
||||
app.use(express.static(PUBLIC));
|
||||
|
||||
Reference in New Issue
Block a user