diff --git a/index.js b/index.js index 6f8b8f7..55917e2 100644 --- a/index.js +++ b/index.js @@ -57,8 +57,18 @@ async function asyncMain() const app = express(); + + const logMiddleware = (req, res, next) => + { + // TODO merge with api.js' version + const ip = req.headers['x-forwarded-for'] || req.ip; + logger.verbose(`[${ip}] ${req.path} (body = ${JSON.stringify(req.body)})`); + next() + } + app.use(express.json()); app.use(express.urlencoded({ extended: false })); + app.use(logMiddleware); app.use('/api', container.ApiRoutes.createRouter(express)); app.use('/', express.static('frontend/dist'));