@umeshindu222/apisnap 1.0.0 โ 1.0.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.
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
> Instant API auto-discovery and health-check CLI for Express.js
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/apisnap)
|
|
5
|
+
[](https://www.npmjs.com/package/@umeshindu222/apisnap)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Why APISnap?
|
|
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
|
|
|
@@ -15,24 +15,28 @@
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Features
|
|
19
19
|
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
20
|
+
- **Auto Route Discovery** โ Scans your Express router stack, no manual config needed
|
|
21
|
+
- **Auth Header Support** โ Pass JWT tokens or API keys via `--header`
|
|
22
|
+
- **Slow Route Detection** โ Flags endpoints that exceed your response time threshold
|
|
23
|
+
- **JSON Report Export** โ Save results to a file for CI/CD pipelines or sharing
|
|
24
|
+
- **Beautiful CLI Output** โ Color-coded results with spinners and summary table
|
|
25
|
+
- **Express v4 & v5** โ Compatible with both versions
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
29
|
## ๐ Quick Start
|
|
30
30
|
|
|
31
|
-
### Step 1:
|
|
31
|
+
### Step 1: Install and add the middleware to your Express app
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @umeshindu222/apisnap
|
|
35
|
+
```
|
|
32
36
|
|
|
33
37
|
```javascript
|
|
34
38
|
const express = require('express');
|
|
35
|
-
const apisnap = require('apisnap');
|
|
39
|
+
const apisnap = require('@umeshindu222/apisnap');
|
|
36
40
|
|
|
37
41
|
const app = express();
|
|
38
42
|
|
|
@@ -49,7 +53,7 @@ app.listen(3000);
|
|
|
49
53
|
### Step 2: Run the health check
|
|
50
54
|
|
|
51
55
|
```bash
|
|
52
|
-
npx apisnap --port 3000
|
|
56
|
+
npx @umeshindu222/apisnap --port 3000
|
|
53
57
|
```
|
|
54
58
|
|
|
55
59
|
That's it. APISnap finds and tests every route automatically.
|
|
@@ -59,7 +63,7 @@ That's it. APISnap finds and tests every route automatically.
|
|
|
59
63
|
## ๐ CLI Usage
|
|
60
64
|
|
|
61
65
|
```bash
|
|
62
|
-
npx apisnap [options]
|
|
66
|
+
npx @umeshindu222/apisnap [options]
|
|
63
67
|
```
|
|
64
68
|
|
|
65
69
|
| Option | Description | Default |
|
|
@@ -73,37 +77,37 @@ npx apisnap [options]
|
|
|
73
77
|
|
|
74
78
|
---
|
|
75
79
|
|
|
76
|
-
##
|
|
80
|
+
## Examples
|
|
77
81
|
|
|
78
82
|
### Basic health check
|
|
79
83
|
```bash
|
|
80
|
-
npx apisnap --port 3000
|
|
84
|
+
npx @umeshindu222/apisnap --port 3000
|
|
81
85
|
```
|
|
82
86
|
|
|
83
|
-
### With authentication
|
|
87
|
+
### With authentication (JWT / Bearer tokens)
|
|
84
88
|
```bash
|
|
85
|
-
npx apisnap --port 3000 --header "Authorization: Bearer eyJhbGci..."
|
|
89
|
+
npx @umeshindu222/apisnap --port 3000 --header "Authorization: Bearer eyJhbGci..."
|
|
86
90
|
```
|
|
87
91
|
|
|
88
92
|
### Custom slow threshold (flag routes > 500ms)
|
|
89
93
|
```bash
|
|
90
|
-
npx apisnap --port 3000 --slow 500
|
|
94
|
+
npx @umeshindu222/apisnap --port 3000 --slow 500
|
|
91
95
|
```
|
|
92
96
|
|
|
93
97
|
### Export report to JSON
|
|
94
98
|
```bash
|
|
95
|
-
npx apisnap --port 3000 --export my-report
|
|
99
|
+
npx @umeshindu222/apisnap --port 3000 --export my-report
|
|
96
100
|
# Creates: my-report.json
|
|
97
101
|
```
|
|
98
102
|
|
|
99
103
|
### All options together
|
|
100
104
|
```bash
|
|
101
|
-
npx apisnap --port 5000 --header "Authorization: Bearer TOKEN" --slow 300 --export ci-report
|
|
105
|
+
npx @umeshindu222/apisnap --port 5000 --header "Authorization: Bearer TOKEN" --slow 300 --export ci-report
|
|
102
106
|
```
|
|
103
107
|
|
|
104
108
|
---
|
|
105
109
|
|
|
106
|
-
##
|
|
110
|
+
## Sample Output
|
|
107
111
|
|
|
108
112
|
```
|
|
109
113
|
๐ธ APISnap v1.0.0
|
|
@@ -111,11 +115,11 @@ npx apisnap --port 5000 --header "Authorization: Bearer TOKEN" --slow 300 --expo
|
|
|
111
115
|
|
|
112
116
|
โ Connected! Found 6 endpoints.
|
|
113
117
|
|
|
114
|
-
โ GET /health [200 OK]
|
|
118
|
+
โ GET /health [200 OK] 3ms
|
|
115
119
|
โ GET /users [200 OK] 12ms
|
|
116
|
-
โ POST /users [200 OK]
|
|
120
|
+
โ POST /users [200 OK] 8ms
|
|
117
121
|
โ GET /users/1 [200 OK] 15ms
|
|
118
|
-
โ ๏ธ GET /reports [200 OK]
|
|
122
|
+
โ ๏ธ GET /reports [200 OK] 543ms โ slow!
|
|
119
123
|
โ DELETE /users/1 [401]
|
|
120
124
|
|
|
121
125
|
๐ Summary:
|
|
@@ -139,13 +143,14 @@ When using `--export`, a structured JSON file is created:
|
|
|
139
143
|
"config": { "port": "3000", "slowThreshold": 200 },
|
|
140
144
|
"summary": { "total": 6, "passed": 5, "failed": 1, "slow": 1 },
|
|
141
145
|
"results": [
|
|
142
|
-
{ "method": "GET", "path": "/health",
|
|
143
|
-
{ "method": "GET", "path": "/users",
|
|
146
|
+
{ "method": "GET", "path": "/health", "status": 200, "duration": 3, "success": true, "slow": false },
|
|
147
|
+
{ "method": "GET", "path": "/users", "status": 200, "duration": 12, "success": true, "slow": false },
|
|
148
|
+
{ "method": "GET", "path": "/reports", "status": 200, "duration": 543,"success": true, "slow": true }
|
|
144
149
|
]
|
|
145
150
|
}
|
|
146
151
|
```
|
|
147
152
|
|
|
148
|
-
> **
|
|
153
|
+
> **CI/CD tip:** Parse `summary.failed` and fail your pipeline build if it's greater than `0`!
|
|
149
154
|
|
|
150
155
|
---
|
|
151
156
|
|
|
@@ -153,9 +158,9 @@ When using `--export`, a structured JSON file is created:
|
|
|
153
158
|
|
|
154
159
|
APISnap uses a two-part architecture:
|
|
155
160
|
|
|
156
|
-
1. **Middleware (The Seeker)** โ `apisnap.init(app)` injects a hidden endpoint `/__apisnap_discovery` into your Express app. When called, it recursively walks the Express router stack and returns a map of every registered route.
|
|
161
|
+
1. **Middleware (The Seeker)** โ `apisnap.init(app)` injects a hidden endpoint `/__apisnap_discovery` into your Express app. When called, it recursively walks the Express router stack and returns a map of every registered route โ including nested sub-routers.
|
|
157
162
|
|
|
158
|
-
2. **CLI Runner (The Checker)** โ `npx apisnap` calls the discovery endpoint, gets the route map, then "pings" each route using axios โ injecting your headers, replacing path params with defaults (`:id` โ `1`), and timing each response.
|
|
163
|
+
2. **CLI Runner (The Checker)** โ `npx @umeshindu222/apisnap` calls the discovery endpoint, gets the route map, then "pings" each route using axios โ injecting your headers, replacing path params with safe defaults (`:id` โ `1`), and timing each response.
|
|
159
164
|
|
|
160
165
|
---
|
|
161
166
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,GAAI,KAAK,GAAG,SAwD5B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,GAAI,KAAK,GAAG,SAwD5B,CAAC;;gBAxDwB,GAAG;;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H,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC;IAEF,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;QACpD,IAAI,CAAC;YACD,0DAA0D;YAC1D,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC;YACzC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,4BAA4B,EAAE,CAAC,CAAC;gBAC9D,OAAO;YACX,CAAC;YACD,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5C,GAAG,CAAC,IAAI,CAAC;gBACL,IAAI,EAAE,mBAAmB;gBACzB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACnC,KAAK,EAAE,SAAS,CAAC,MAAM;gBACvB,SAAS,EAAE,SAAS;aACvB,CAAC,CAAC;QACP,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YACd,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CACP,mBAAmB,EACnB,mCAAmC,cAAc,EAAE,CACtD,CAAC;AACN,CAAC,CAAC;AAxDW,QAAA,IAAI,QAwDf;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.2",
|
|
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",
|
|
@@ -38,4 +38,4 @@
|
|
|
38
38
|
"ts-node": "^10.9.2",
|
|
39
39
|
"typescript": "^5.9.3"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|