Commit 6623d664cb6fd97dd3cdf542bcdf3b38b7200489

Authored by Adhidarma Hadiwinoto
1 parent 0a721d3678
Exists in master and in 1 other branch dev

xid using uuid/v1

Showing 1 changed file with 3 additions and 2 deletions Inline Diff

lib/listener-partner/middlewares/common.js
1 'use strict'; 1 'use strict';
2 2
3 const uniqid = require('uniqid'); 3 // const uniqid = require('uniqid');
4 const uuidv1 = require('uuid/v1');
4 const logger = require('komodo-sdk/logger'); 5 const logger = require('komodo-sdk/logger');
5 6
6 module.exports = function common(req, res, next) { 7 module.exports = function common(req, res, next) {
7 if (req.url.search('/favicon.ico') === 0) { 8 if (req.url.search('/favicon.ico') === 0) {
8 res.sendStatus(404); 9 res.sendStatus(404);
9 return; 10 return;
10 } 11 }
11 12
12 res.locals.xid = uniqid(); 13 res.locals.xid = uuidv1();
13 res.locals.x_http_request_ts = new Date(); 14 res.locals.x_http_request_ts = new Date();
14 15
15 logger.info('Got request from partner', { 16 logger.info('Got request from partner', {
16 xid: res.locals.xid, 17 xid: res.locals.xid,
17 ip: req.ip, 18 ip: req.ip,
18 method: req.method, 19 method: req.method,
19 path: req.path, 20 path: req.path,
20 url: req.url, 21 url: req.url,
21 qs: req.query, 22 qs: req.query,
22 }); 23 });
23 next(); 24 next();
24 }; 25 };
25 26