@aimeloic/monkey-tester 3.0.1 → 3.0.3

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.
package/htmlTemplate.js CHANGED
@@ -381,4 +381,4 @@ function getHtmlTemplate(endpoints) {
381
381
  </html>`;
382
382
  }
383
383
 
384
- module.exports = { getHtmlTemplate };
384
+ export { getHtmlTemplate };
package/index.js CHANGED
@@ -1,13 +1,7 @@
1
- 'use strict';
1
+ import { endtesterExpress } from './monkey.js';
2
2
 
3
- // 1. Core internal require hook (monkey.js uses module.exports)
4
- const { endtesterExpress } = require('./monkey.js');
3
+ // Named export for: import { endtesterExpress } from '@aimeloic/monkey-tester'
4
+ export { endtesterExpress };
5
5
 
6
- // 2. Compatibility layer for legacy setups using: const x = require('@aimeloic/monkey-tester')
7
- module.exports = { endtesterExpress };
8
-
9
- // 3. Compatibility layer for ES module environments using: import { endtesterExpress } from '...'
10
- module.exports.endtesterExpress = endtesterExpress;
11
-
12
- // 4. Compatibility layer for ES module environments using: import monkeyTester from '...'
13
- module.exports.default = { endtesterExpress };
6
+ // Default export for: import monkeyTester from '@aimeloic/monkey-tester'
7
+ export default { endtesterExpress };
package/monkey.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { getHtmlTemplate } = require('./htmlTemplate');
3
+ import { getHtmlTemplate } from './htmlTemplate.js';
4
4
 
5
5
  // ─── Field type inference ─────────────────────────────────────────────────────
6
6
  function inferType(name) {
@@ -173,13 +173,19 @@ function parseStack(stack, detectedEndpoints, prefix = '') {
173
173
  }
174
174
 
175
175
  // ─── Middleware ───────────────────────────────────────────────────────────────
176
+ // ─── Middleware in monkey.js ──────────────────────────────────────────────────
176
177
  function endtesterExpress() {
177
178
  return function monkeyTesterMiddleware(req, res, next) {
178
- if (req.path !== '/api/tester' && req.path !== '/api/tester/') {
179
+ // Standard structural path cleaning
180
+ const normalPath = req.path.replace(/\/$/, ''); // removes trailing slash
181
+
182
+ if (normalPath !== '/api/tester') {
179
183
  return next();
180
184
  }
181
185
 
182
186
  const app = req.app;
187
+
188
+ // CRITICAL FIX: Reset the detected endpoints on each call to prevent stale empty states
183
189
  const detectedEndpoints = {};
184
190
 
185
191
  const rootStack =
@@ -187,12 +193,14 @@ function endtesterExpress() {
187
193
  (app.router && app.router.stack) || // Express 5
188
194
  [];
189
195
 
196
+ // Scan the live compiled routing stack
190
197
  parseStack(rootStack, detectedEndpoints);
191
198
 
199
+ // Render page template
192
200
  const html = getHtmlTemplate(detectedEndpoints);
193
201
  res.setHeader('Content-Type', 'text/html');
194
202
  return res.send(html);
195
203
  };
196
204
  }
197
205
 
198
- module.exports = { endtesterExpress };
206
+ export { endtesterExpress };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aimeloic/monkey-tester",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Auto route scanning visual runner dashboard.",
5
5
  "main": "index.js",
6
6
  "type": "module",