fixup backend

This commit is contained in:
2026-06-06 08:59:18 +05:30
parent 9168ece209
commit 1789fc0abe
3 changed files with 219 additions and 10 deletions

View File

@@ -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'];