@commercetools-backend/loggers 27.9.0 → 27.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72,11 +72,11 @@ const parseIps = request => {
72
72
  return remoteAddresses;
73
73
  };
74
74
  const createAccessLogSkipper = options => request => {
75
- var _context;
75
+ var _context, _options$ignoreUrls;
76
76
  if (Boolean(options.silent)) {
77
77
  return true;
78
78
  }
79
- const hasMatchingIgnoreUrl = _someInstanceProperty__default["default"](_context = options.ignoreUrls ?? []).call(_context, uriPathOrRegex => {
79
+ const hasMatchingIgnoreUrl = _someInstanceProperty__default["default"](_context = (_options$ignoreUrls = options.ignoreUrls) !== null && _options$ignoreUrls !== void 0 ? _options$ignoreUrls : []).call(_context, uriPathOrRegex => {
80
80
  if (typeof uriPathOrRegex === 'string') {
81
81
  return request.originalUrl === uriPathOrRegex;
82
82
  }
@@ -86,29 +86,31 @@ const createAccessLogSkipper = options => request => {
86
86
  };
87
87
  const mapRequestMetadata = request => {
88
88
  try {
89
- const remoteAddress = request.socket?.remoteAddress;
89
+ var _request$socket;
90
+ const remoteAddress = (_request$socket = request.socket) === null || _request$socket === void 0 ? void 0 : _request$socket.remoteAddress;
90
91
  const proxyIps = parseIps(request);
91
92
  const _proxyIps = _slicedToArray(proxyIps, 1),
92
93
  clientIp = _proxyIps[0];
93
94
  return _objectSpread({
94
- clientIp: clientIp ?? remoteAddress,
95
+ clientIp: clientIp !== null && clientIp !== void 0 ? clientIp : remoteAddress,
95
96
  proxyIps,
96
97
  hostname: request.socket ? request.hostname : undefined
97
98
  }, remoteAddress ? {
98
99
  remoteAddress
99
100
  } : {});
100
101
  } catch (error) {
101
- console.error(`Failed to parse request metadata`, error);
102
+ console.error("Failed to parse request metadata", error);
102
103
  return {};
103
104
  }
104
105
  };
105
106
 
106
107
  const createAccessLoggerMiddleware = function () {
108
+ var _options$formatters, _options$level;
107
109
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
108
- const formatters = winston__namespace["default"].format.combine(winston__namespace["default"].format.timestamp(), ...(options.formatters ?? []), options.json ? winston__namespace["default"].format.json() : winston__namespace["default"].format.cli());
110
+ const formatters = winston__namespace["default"].format.combine(winston__namespace["default"].format.timestamp(), ...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__namespace["default"].format.json() : winston__namespace["default"].format.cli());
109
111
  const skip = createAccessLogSkipper(options);
110
112
  return expressWinston__default["default"].logger({
111
- level: options.level ?? 'info',
113
+ level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
112
114
  transports: [new winston__namespace["default"].transports.Console()],
113
115
  format: formatters,
114
116
  meta: true,
@@ -121,10 +123,11 @@ const createAccessLoggerMiddleware = function () {
121
123
  };
122
124
 
123
125
  const createApplicationLogger = function () {
126
+ var _options$formatters, _options$level;
124
127
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
125
- const formatters = winston__namespace.format.combine(...(options.formatters ?? []), options.json ? winston__namespace.format.json() : winston__namespace.format.combine(winston__namespace.format.cli(), winston__namespace.format.simple()));
128
+ const formatters = winston__namespace.format.combine(...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__namespace.format.json() : winston__namespace.format.combine(winston__namespace.format.cli(), winston__namespace.format.simple()));
126
129
  return winston__namespace.createLogger({
127
- level: options.level ?? 'info',
130
+ level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
128
131
  format: formatters,
129
132
  transports: [new winston__namespace.transports.Console({
130
133
  silent: Boolean(options.silent)
@@ -147,8 +150,9 @@ function redactFieldsFormatter(options) {
147
150
  }
148
151
 
149
152
  function rewriteField(info, field) {
153
+ var _field$preserveFromFi;
150
154
  const fromFieldValue = getIn__default["default"](info, field.from);
151
- const preserveFromField = field.preserveFromField ?? false;
155
+ const preserveFromField = (_field$preserveFromFi = field.preserveFromField) !== null && _field$preserveFromFi !== void 0 ? _field$preserveFromFi : false;
152
156
  if (fromFieldValue) {
153
157
  if (!preserveFromField) {
154
158
  unsetIn__default["default"](info, field.from);
@@ -72,11 +72,11 @@ const parseIps = request => {
72
72
  return remoteAddresses;
73
73
  };
74
74
  const createAccessLogSkipper = options => request => {
75
- var _context;
75
+ var _context, _options$ignoreUrls;
76
76
  if (Boolean(options.silent)) {
77
77
  return true;
78
78
  }
79
- const hasMatchingIgnoreUrl = _someInstanceProperty__default["default"](_context = options.ignoreUrls ?? []).call(_context, uriPathOrRegex => {
79
+ const hasMatchingIgnoreUrl = _someInstanceProperty__default["default"](_context = (_options$ignoreUrls = options.ignoreUrls) !== null && _options$ignoreUrls !== void 0 ? _options$ignoreUrls : []).call(_context, uriPathOrRegex => {
80
80
  if (typeof uriPathOrRegex === 'string') {
81
81
  return request.originalUrl === uriPathOrRegex;
82
82
  }
@@ -86,29 +86,31 @@ const createAccessLogSkipper = options => request => {
86
86
  };
87
87
  const mapRequestMetadata = request => {
88
88
  try {
89
- const remoteAddress = request.socket?.remoteAddress;
89
+ var _request$socket;
90
+ const remoteAddress = (_request$socket = request.socket) === null || _request$socket === void 0 ? void 0 : _request$socket.remoteAddress;
90
91
  const proxyIps = parseIps(request);
91
92
  const _proxyIps = _slicedToArray(proxyIps, 1),
92
93
  clientIp = _proxyIps[0];
93
94
  return _objectSpread({
94
- clientIp: clientIp ?? remoteAddress,
95
+ clientIp: clientIp !== null && clientIp !== void 0 ? clientIp : remoteAddress,
95
96
  proxyIps,
96
97
  hostname: request.socket ? request.hostname : undefined
97
98
  }, remoteAddress ? {
98
99
  remoteAddress
99
100
  } : {});
100
101
  } catch (error) {
101
- console.error(`Failed to parse request metadata`, error);
102
+ console.error("Failed to parse request metadata", error);
102
103
  return {};
103
104
  }
104
105
  };
105
106
 
106
107
  const createAccessLoggerMiddleware = function () {
108
+ var _options$formatters, _options$level;
107
109
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
108
- const formatters = winston__namespace["default"].format.combine(winston__namespace["default"].format.timestamp(), ...(options.formatters ?? []), options.json ? winston__namespace["default"].format.json() : winston__namespace["default"].format.cli());
110
+ const formatters = winston__namespace["default"].format.combine(winston__namespace["default"].format.timestamp(), ...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__namespace["default"].format.json() : winston__namespace["default"].format.cli());
109
111
  const skip = createAccessLogSkipper(options);
110
112
  return expressWinston__default["default"].logger({
111
- level: options.level ?? 'info',
113
+ level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
112
114
  transports: [new winston__namespace["default"].transports.Console()],
113
115
  format: formatters,
114
116
  meta: true,
@@ -121,10 +123,11 @@ const createAccessLoggerMiddleware = function () {
121
123
  };
122
124
 
123
125
  const createApplicationLogger = function () {
126
+ var _options$formatters, _options$level;
124
127
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
125
- const formatters = winston__namespace.format.combine(...(options.formatters ?? []), options.json ? winston__namespace.format.json() : winston__namespace.format.combine(winston__namespace.format.cli(), winston__namespace.format.simple()));
128
+ const formatters = winston__namespace.format.combine(...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__namespace.format.json() : winston__namespace.format.combine(winston__namespace.format.cli(), winston__namespace.format.simple()));
126
129
  return winston__namespace.createLogger({
127
- level: options.level ?? 'info',
130
+ level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
128
131
  format: formatters,
129
132
  transports: [new winston__namespace.transports.Console({
130
133
  silent: Boolean(options.silent)
@@ -147,8 +150,9 @@ function redactFieldsFormatter(options) {
147
150
  }
148
151
 
149
152
  function rewriteField(info, field) {
153
+ var _field$preserveFromFi;
150
154
  const fromFieldValue = getIn__default["default"](info, field.from);
151
- const preserveFromField = field.preserveFromField ?? false;
155
+ const preserveFromField = (_field$preserveFromFi = field.preserveFromField) !== null && _field$preserveFromFi !== void 0 ? _field$preserveFromFi : false;
152
156
  if (fromFieldValue) {
153
157
  if (!preserveFromField) {
154
158
  unsetIn__default["default"](info, field.from);
@@ -31,11 +31,11 @@ const parseIps = request => {
31
31
  return remoteAddresses;
32
32
  };
33
33
  const createAccessLogSkipper = options => request => {
34
- var _context;
34
+ var _context, _options$ignoreUrls;
35
35
  if (Boolean(options.silent)) {
36
36
  return true;
37
37
  }
38
- const hasMatchingIgnoreUrl = _someInstanceProperty(_context = options.ignoreUrls ?? []).call(_context, uriPathOrRegex => {
38
+ const hasMatchingIgnoreUrl = _someInstanceProperty(_context = (_options$ignoreUrls = options.ignoreUrls) !== null && _options$ignoreUrls !== void 0 ? _options$ignoreUrls : []).call(_context, uriPathOrRegex => {
39
39
  if (typeof uriPathOrRegex === 'string') {
40
40
  return request.originalUrl === uriPathOrRegex;
41
41
  }
@@ -45,29 +45,31 @@ const createAccessLogSkipper = options => request => {
45
45
  };
46
46
  const mapRequestMetadata = request => {
47
47
  try {
48
- const remoteAddress = request.socket?.remoteAddress;
48
+ var _request$socket;
49
+ const remoteAddress = (_request$socket = request.socket) === null || _request$socket === void 0 ? void 0 : _request$socket.remoteAddress;
49
50
  const proxyIps = parseIps(request);
50
51
  const _proxyIps = _slicedToArray(proxyIps, 1),
51
52
  clientIp = _proxyIps[0];
52
53
  return _objectSpread({
53
- clientIp: clientIp ?? remoteAddress,
54
+ clientIp: clientIp !== null && clientIp !== void 0 ? clientIp : remoteAddress,
54
55
  proxyIps,
55
56
  hostname: request.socket ? request.hostname : undefined
56
57
  }, remoteAddress ? {
57
58
  remoteAddress
58
59
  } : {});
59
60
  } catch (error) {
60
- console.error(`Failed to parse request metadata`, error);
61
+ console.error("Failed to parse request metadata", error);
61
62
  return {};
62
63
  }
63
64
  };
64
65
 
65
66
  const createAccessLoggerMiddleware = function () {
67
+ var _options$formatters, _options$level;
66
68
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
67
- const formatters = winston__default.format.combine(winston__default.format.timestamp(), ...(options.formatters ?? []), options.json ? winston__default.format.json() : winston__default.format.cli());
69
+ const formatters = winston__default.format.combine(winston__default.format.timestamp(), ...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston__default.format.json() : winston__default.format.cli());
68
70
  const skip = createAccessLogSkipper(options);
69
71
  return expressWinston.logger({
70
- level: options.level ?? 'info',
72
+ level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
71
73
  transports: [new winston__default.transports.Console()],
72
74
  format: formatters,
73
75
  meta: true,
@@ -80,10 +82,11 @@ const createAccessLoggerMiddleware = function () {
80
82
  };
81
83
 
82
84
  const createApplicationLogger = function () {
85
+ var _options$formatters, _options$level;
83
86
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
84
- const formatters = winston.format.combine(...(options.formatters ?? []), options.json ? winston.format.json() : winston.format.combine(winston.format.cli(), winston.format.simple()));
87
+ const formatters = winston.format.combine(...((_options$formatters = options.formatters) !== null && _options$formatters !== void 0 ? _options$formatters : []), options.json ? winston.format.json() : winston.format.combine(winston.format.cli(), winston.format.simple()));
85
88
  return winston.createLogger({
86
- level: options.level ?? 'info',
89
+ level: (_options$level = options.level) !== null && _options$level !== void 0 ? _options$level : 'info',
87
90
  format: formatters,
88
91
  transports: [new winston.transports.Console({
89
92
  silent: Boolean(options.silent)
@@ -106,8 +109,9 @@ function redactFieldsFormatter(options) {
106
109
  }
107
110
 
108
111
  function rewriteField(info, field) {
112
+ var _field$preserveFromFi;
109
113
  const fromFieldValue = getIn(info, field.from);
110
- const preserveFromField = field.preserveFromField ?? false;
114
+ const preserveFromField = (_field$preserveFromFi = field.preserveFromField) !== null && _field$preserveFromFi !== void 0 ? _field$preserveFromFi : false;
111
115
  if (fromFieldValue) {
112
116
  if (!preserveFromField) {
113
117
  unsetIn(info, field.from);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-backend/loggers",
3
- "version": "27.9.0",
3
+ "version": "27.9.1",
4
4
  "description": "Opinionated JSON loggers for HTTP server applications",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -39,13 +39,13 @@
39
39
  "lodash": "4.18.1",
40
40
  "logform": "2.7.0",
41
41
  "triple-beam": "1.4.1",
42
- "winston": "3.17.0"
42
+ "winston": "3.19.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@tsconfig/node22": "^22.0.0",
45
+ "@tsconfig/node24": "^24.0.0",
46
46
  "@types/express": "^4.17.17",
47
47
  "express": "^4.21.2",
48
- "typescript": "5.9.2"
48
+ "typescript": "5.9.3"
49
49
  },
50
50
  "engines": {
51
51
  "node": "18.x || 20.x || >=22.0.0"