Blame view
lib/middlewares/common.js
908 Bytes
cd4feda87
|
1 2 3 |
const MODULE_NAME = 'MIDDLEWARES'; const uuidv1 = require('uuid/v1'); |
969370309
|
4 |
const uniqid = require('uniqid'); |
cd4feda87
|
5 6 |
const config = require('komodo-sdk/config'); |
810fa18da
|
7 |
const logger = require('tektrans-logger'); |
ab5828535
|
8 9 10 11 12 13 |
module.exports = function common(req, res, next) { if (req.url.search('/favicon.ico') === 0) { res.sendStatus(404); return; } |
cd4feda87
|
14 15 |
res.locals.xid = config.xid_from_uuid ? uuidv1() : uniqid(); |
c98ae8750
|
16 |
res.locals.x_http_request_ts = new Date(); |
cd4feda87
|
17 |
logger.info(`${MODULE_NAME}.COMMON B6257542: Got a request`, { |
ab5828535
|
18 |
xid: res.locals.xid, |
cfdcd1733
|
19 |
pid: process.pid, |
cd4feda87
|
20 |
subsystem: res.locals.httpgetx_subsystem, |
57fe0b084
|
21 22 |
userAgent: req.get('user-agent'), requesterIp: req.ip, |
ab5828535
|
23 |
method: req.method, |
57fe0b084
|
24 |
requestContentType: req.get('content-type'), |
ab5828535
|
25 26 27 |
path: req.path, url: req.url, qs: req.query, |
f2c18879a
|
28 |
body: req.body, |
ab5828535
|
29 30 31 |
}); next(); }; |