@umeshindu222/apisnap 1.0.2 → 1.0.4
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/README.md +1 -1
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +30 -10
- package/dist/middleware/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
**The Problem:** Every time you make a change to your Express.js backend, you have to manually open Postman, find every route, and click "Send" one by one. For a project with 20+ endpoints, this is slow, error-prone, and boring.
|
|
13
13
|
|
|
14
|
-
**The Solution:** APISnap plugs directly into your Express app, **automatically discovers every route you've registered**, and then health-checks all of them in seconds
|
|
14
|
+
**The Solution:** APISnap plugs directly into your Express app, **automatically discovers every route you've registered**, and then health-checks all of them in seconds with zero configuration.
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,GAAI,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,GAAI,KAAK,GAAG,SA4E5B,CAAC;;gBA5EwB,GAAG;;AA8E7B,wBAAwB"}
|
package/dist/middleware/index.js
CHANGED
|
@@ -15,22 +15,42 @@ const init = (app) => {
|
|
|
15
15
|
}
|
|
16
16
|
else if (layer.handle && layer.handle.stack) {
|
|
17
17
|
// Nested Router - GO DEEPER
|
|
18
|
-
// Extract the prefix from the regexp (e.g. /api)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
// Extract the prefix from the regexp (e.g. /api or /api/community)
|
|
19
|
+
let rStr = layer.regexp.toString();
|
|
20
|
+
let routerPrefix = '';
|
|
21
|
+
// Try to match standard Express router regexp: /^\/api\/?(?=\/|$)/i
|
|
22
|
+
const standardMatch = rStr.match(/^\/\^\\\/(.*?)\\\/\?\(\?\=\\\/\|\$\)\/i$/);
|
|
23
|
+
if (standardMatch) {
|
|
24
|
+
routerPrefix = standardMatch[1];
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// Fallback for custom or older regexes
|
|
28
|
+
const fallbackMatch = rStr.match(/^\/\^\\?(.*?)\\?\/?(?:\(\?=\\\/\|\$\))?\//);
|
|
29
|
+
routerPrefix = fallbackMatch ? fallbackMatch[1] : '';
|
|
30
|
+
}
|
|
31
|
+
routerPrefix = routerPrefix.replace(/\\\//g, '/');
|
|
32
|
+
if (routerPrefix && !routerPrefix.startsWith('/')) {
|
|
33
|
+
routerPrefix = '/' + routerPrefix;
|
|
34
|
+
}
|
|
35
|
+
// Avoid double slashes in concatenation
|
|
36
|
+
const newPrefix = (prefix + routerPrefix).replace(/\/\//g, '/');
|
|
37
|
+
routes = routes.concat(splitRoutes(layer.handle.stack, newPrefix));
|
|
26
38
|
}
|
|
27
39
|
});
|
|
28
40
|
return routes;
|
|
29
41
|
};
|
|
30
42
|
app.get(DISCOVERY_PATH, (req, res) => {
|
|
31
43
|
try {
|
|
32
|
-
// Express
|
|
33
|
-
|
|
44
|
+
// Safely get Express router (v4 uses _router, v5 uses router)
|
|
45
|
+
let router = app._router;
|
|
46
|
+
if (!router) {
|
|
47
|
+
try {
|
|
48
|
+
router = app.router;
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
// Ignore getter deprecation errors from Express 4
|
|
52
|
+
}
|
|
53
|
+
}
|
|
34
54
|
if (!router) {
|
|
35
55
|
res.status(500).json({ error: 'Router not initialized yet' });
|
|
36
56
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":";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,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CACP,mBAAmB,EACnB,mCAAmC,cAAc,EAAE,CACtD,CAAC;AACN,CAAC,CAAC;AA5EW,QAAA,IAAI,QA4Ef;AAEF,kBAAe,EAAE,IAAI,EAAJ,YAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umeshindu222/apisnap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Instant API auto-discovery and health-check CLI for Express.js",
|
|
5
5
|
"main": "dist/middleware/index.js",
|
|
6
6
|
"types": "dist/middleware/index.d.ts",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"axios": "^1.13.6",
|
|
31
31
|
"chalk": "^5.6.2",
|
|
32
32
|
"commander": "^14.0.3",
|
|
33
|
+
"express": "^4.22.1",
|
|
33
34
|
"ora": "^9.3.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|