Blame view
lib/middlewares/common.js
816 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'); |
ab5828535
|
7 8 9 10 11 12 13 |
const logger = require('komodo-sdk/logger'); 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, |
f2c18879a
|
21 |
requester_ip: req.ip, |
ab5828535
|
22 23 24 25 |
method: req.method, path: req.path, url: req.url, qs: req.query, |
f2c18879a
|
26 |
body: req.body, |
ab5828535
|
27 28 29 |
}); next(); }; |