@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 +1 -1
- package/index.js +5 -11
- package/monkey.js +11 -3
- package/package.json +1 -1
package/htmlTemplate.js
CHANGED
package/index.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { endtesterExpress } from './monkey.js';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
|
|
3
|
+
// Named export for: import { endtesterExpress } from '@aimeloic/monkey-tester'
|
|
4
|
+
export { endtesterExpress };
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
206
|
+
export { endtesterExpress };
|