feat(logging): enhance HTTP request logging with additional payload details

- Introduced new fields in the HttpPageFetchLog model to capture request and response headers, bodies, and method for improved logging granularity.
- Updated the logging service to serialize and store these new details during HTTP fetch operations, enhancing traceability and debugging capabilities.
- Modified the clickTtHttpPageRoutes to include the new logging features, allowing for optional payload inclusion in log queries.
This commit is contained in:
Torsten Schulz (local)
2026-03-10 22:26:37 +01:00
parent 4f3a1829ca
commit 0e4d1707fd
6 changed files with 143 additions and 23 deletions

View File

@@ -59,6 +59,11 @@ import HttpError from './exceptions/HttpError.js';
const app = express();
const port = process.env.PORT || 3005;
function captureRawBody(req, res, buf, encoding) {
if (!buf || buf.length === 0) return;
req.rawBody = buf.toString(encoding || 'utf8');
}
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@@ -70,8 +75,8 @@ app.use(cors({
allowedHeaders: ['Content-Type', 'Authorization', 'authcode', 'userid']
}));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.json({ verify: captureRawBody }));
app.use(express.urlencoded({ extended: true, verify: captureRawBody }));
// Request Logging Middleware - loggt alle API-Requests
// Wichtig: userId wird später in authMiddleware gesetzt, aber Middleware funktioniert auch ohne
@@ -421,4 +426,4 @@ app.use((err, req, res, next) => {
} catch (err) {
console.error('Unable to synchronize the database:', err);
}
})();
})();