fixup backend
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
if (process.stdout._handle && typeof process.stdout._handle.setBlocking === 'function') {
|
||||
process.stdout._handle.setBlocking(true);
|
||||
}
|
||||
if (process.stderr._handle && typeof process.stderr._handle.setBlocking === 'function') {
|
||||
process.stderr._handle.setBlocking(true);
|
||||
}
|
||||
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const bcrypt = require('bcrypt');
|
||||
@@ -11,6 +18,17 @@ const PORT = process.env.PORT || 5000;
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
// Request logger middleware
|
||||
app.use((req, res, next) => {
|
||||
console.log(`${new Date().toISOString()} - ${req.method} ${req.url}`);
|
||||
if (req.body && Object.keys(req.body).length > 0) {
|
||||
const logBody = { ...req.body };
|
||||
if (logBody.password) logBody.password = '[REDACTED]';
|
||||
console.log(' Body:', JSON.stringify(logBody));
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
// Middleware to verify JWT token
|
||||
const authenticateToken = (req, res, next) => {
|
||||
const authHeader = req.headers['authorization'];
|
||||
|
||||
Reference in New Issue
Block a user