@contrast/route-coverage 1.11.2 → 1.12.0

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/lib/index.js +8 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -32,8 +32,9 @@ module.exports = function init(core) {
32
32
 
33
33
  /** @type {Map<string, import('@contrast/common').RouteInfo>} */
34
34
  const routeInfo = new Map();
35
+ const recentlyObserved = new Set();
35
36
 
36
- core.routeCoverage = {
37
+ const routeCoverage = core.routeCoverage = {
37
38
  discover(info) {
38
39
  routeInfo.set(routeIdentifier(info), info);
39
40
  messages.emit(Event.ROUTE_COVERAGE_DISCOVERY, info);
@@ -61,6 +62,10 @@ module.exports = function init(core) {
61
62
  store.route = route;
62
63
  }
63
64
 
65
+ if (recentlyObserved.has(route.signature)) return;
66
+
67
+ recentlyObserved.add(route.signature);
68
+
64
69
  // these events need source correlation
65
70
  messages.emit(Event.ROUTE_COVERAGE_OBSERVATION, {
66
71
  ...route,
@@ -70,6 +75,7 @@ module.exports = function init(core) {
70
75
 
71
76
  install() {
72
77
  callChildComponentMethodsSync(this, 'install');
78
+ setInterval(() => recentlyObserved.clear(), 10000).unref();
73
79
  },
74
80
  };
75
81
 
@@ -78,5 +84,5 @@ module.exports = function init(core) {
78
84
  require('./install/fastify')(core);
79
85
  require('./install/koa')(core);
80
86
 
81
- return core.routeCoverage;
87
+ return routeCoverage;
82
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/route-coverage",
3
- "version": "1.11.2",
3
+ "version": "1.12.0",
4
4
  "description": "Handles route discovery and observation",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",