nest-devtools 0.1.2 → 0.1.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/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # nest-devtools
2
+
3
+ A zero-config developer dashboard for NestJS applications.
4
+
5
+ `nest-devtools` mounts a browser UI inside your Nest app so you can watch logs and HTTP requests in real time while developing.
6
+
7
+ ## Features
8
+
9
+ - Zero-config module setup with `DevtoolsModule.forRoot()`
10
+ - Live logs captured from Nest `Logger` and `ConsoleLogger`
11
+ - Live HTTP request tracing with method, path, status, duration, and redacted headers
12
+ - In-memory circular-style buffers for logs and requests
13
+ - Embedded dashboard UI served by your Nest app
14
+ - Raw WebSocket live updates, no frontend framework required
15
+ - Auto-disabled when `NODE_ENV === 'production'`
16
+
17
+ ## Compatibility
18
+
19
+ - NestJS `^10.0.0 || ^11.0.0`
20
+ - `reflect-metadata` `^0.1.12 || ^0.2.0`
21
+ - `rxjs` `^7.8.0`
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ npm i nest-devtools
27
+ ```
28
+
29
+ If you are testing the package locally before publishing a new version, install it from the repo instead of npm:
30
+
31
+ ```bash
32
+ npm i /absolute/path/to/nest-devtool
33
+ ```
34
+
35
+ Or pack it first and install the generated tarball:
36
+
37
+ ```bash
38
+ npm pack
39
+ npm i ./nest-devtools-0.1.2.tgz
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ Import the module in your app module:
45
+
46
+ ```ts
47
+ import { Module } from '@nestjs/common';
48
+ import { DevtoolsModule } from 'nest-devtools';
49
+
50
+ @Module({
51
+ imports: [DevtoolsModule.forRoot()],
52
+ })
53
+ export class AppModule {}
54
+ ```
55
+
56
+ Start your app and open:
57
+
58
+ ```txt
59
+ http://localhost:3000/__devtools__
60
+ ```
61
+
62
+ That is enough for the dashboard to start collecting:
63
+
64
+ - Nest logs
65
+ - request traces
66
+ - live updates through the built-in WebSocket endpoint
67
+
68
+ ## Configuration
69
+
70
+ ```ts
71
+ import { Module } from '@nestjs/common';
72
+ import { DevtoolsModule } from 'nest-devtools';
73
+
74
+ @Module({
75
+ imports: [
76
+ DevtoolsModule.forRoot({
77
+ maxLogs: 500,
78
+ maxRequests: 500,
79
+ path: '__devtools__',
80
+ }),
81
+ ],
82
+ })
83
+ export class AppModule {}
84
+ ```
85
+
86
+ ### Options
87
+
88
+ | Option | Type | Default | Description |
89
+ | --- | --- | --- | --- |
90
+ | `maxLogs` | `number` | `500` | Maximum number of log entries kept in memory |
91
+ | `maxRequests` | `number` | `500` | Maximum number of request entries kept in memory |
92
+ | `path` | `string` | `__devtools__` | Base path used for the dashboard and API routes |
93
+
94
+ Examples:
95
+
96
+ - `path: '__devtools__'` -> `/__devtools__`
97
+ - `path: '/inspect/'` -> `/inspect`
98
+ - `path: 'internal/devtools'` -> `/internal/devtools`
99
+
100
+ ## How To Use It
101
+
102
+ Once your Nest app is running:
103
+
104
+ 1. Open the dashboard URL in your browser.
105
+ 2. Hit your normal API routes from Postman, your frontend, curl, or the browser.
106
+ 3. Watch logs and requests appear live in the dashboard.
107
+
108
+ ### Logs Tab
109
+
110
+ - Shows `log`, `warn`, `error`, `debug`, and `verbose`
111
+ - Includes timestamp, level, context, and message
112
+ - Supports client-side search and level filters
113
+ - Can be cleared from the UI
114
+
115
+ ### Requests Tab
116
+
117
+ - Shows timestamp, method, path, status, and duration
118
+ - Streams requests live as they finish
119
+ - Lets you filter by HTTP method and status range
120
+ - Expands each row to show the full path and captured headers
121
+
122
+ ## What Gets Captured
123
+
124
+ ### Logs
125
+
126
+ The package captures logs that go through Nest's built-in logging path:
127
+
128
+ - `Logger.log()`
129
+ - `Logger.warn()`
130
+ - `Logger.error()`
131
+ - `Logger.debug()`
132
+ - `Logger.verbose()`
133
+ - direct `ConsoleLogger` usage
134
+
135
+ ### Requests
136
+
137
+ The package captures HTTP requests handled by Nest and stores:
138
+
139
+ - method
140
+ - path
141
+ - status code
142
+ - duration in milliseconds
143
+ - timestamp
144
+ - optional request headers
145
+
146
+ Sensitive headers are redacted:
147
+
148
+ - `authorization`
149
+ - `cookie`
150
+ - `set-cookie`
151
+ - `proxy-authorization`
152
+ - `x-api-key`
153
+
154
+ ## Routes
155
+
156
+ With the default path, the module exposes:
157
+
158
+ | Method | Path | Description |
159
+ | --- | --- | --- |
160
+ | `GET` | `/__devtools__` | Dashboard UI |
161
+ | `GET` | `/__devtools__/api/logs` | Current log buffer |
162
+ | `GET` | `/__devtools__/api/requests` | Current request buffer |
163
+ | `DELETE` | `/__devtools__/api/logs` | Clear logs |
164
+ | `DELETE` | `/__devtools__/api/requests` | Clear requests |
165
+ | `WS` | `/__devtools__/ws` | Live realtime stream |
166
+
167
+ ## Production Behavior
168
+
169
+ If `NODE_ENV === 'production'`, `DevtoolsModule.forRoot()` becomes a no-op:
170
+
171
+ - no dashboard route
172
+ - no API endpoints
173
+ - no request interceptor
174
+ - no logger patching
175
+ - no WebSocket listener
176
+
177
+ ## Notes
178
+
179
+ - Everything is in memory only.
180
+ - The dashboard does not persist data across restarts.
181
+ - The dashboard skips recording its own requests to avoid self-noise.
182
+ - This package is intended for development, not production monitoring.
183
+
184
+ ## Example App In This Repo
185
+
186
+ Run the included example app:
187
+
188
+ ```bash
189
+ npm install
190
+ npm run example:start
191
+ ```
192
+
193
+ Then open:
194
+
195
+ ```txt
196
+ http://localhost:3000/__devtools__
197
+ ```
198
+
199
+ Useful example routes:
200
+
201
+ - `GET /`
202
+ - `GET /users/123`
203
+ - `GET /warn`
204
+ - `GET /fail`
205
+
206
+ ## Development
207
+
208
+ ```bash
209
+ npm install
210
+ npm run build
211
+ npm test
212
+ ```
@@ -635,7 +635,7 @@ const DASHBOARD_TEMPLATE = `<!DOCTYPE html>
635
635
  </div>
636
636
 
637
637
  <script>
638
- window.__NEST_DEVTOOLS_CONFIG__ = __NEST_DEVTOOLS_CONFIG__;
638
+ window.__NEST_DEVTOOLS_CONFIG__ = __NEST_DEVTOOLS_JSON__;
639
639
 
640
640
  (function () {
641
641
  var config = window.__NEST_DEVTOOLS_CONFIG__;
@@ -1045,7 +1045,7 @@ const DASHBOARD_TEMPLATE = `<!DOCTYPE html>
1045
1045
  </body>
1046
1046
  </html>`;
1047
1047
  function renderDashboardHtml(basePath) {
1048
- return DASHBOARD_TEMPLATE.replace('__NEST_DEVTOOLS_CONFIG__', JSON.stringify({
1048
+ return DASHBOARD_TEMPLATE.replace('__NEST_DEVTOOLS_JSON__', JSON.stringify({
1049
1049
  basePath,
1050
1050
  }));
1051
1051
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.html.js","sourceRoot":"","sources":["../../src/dashboard/index.html.ts"],"names":[],"mappings":";;AAohCA,kDAOC;AA3hCD,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAkhCnB,CAAC;AAET,SAAgB,mBAAmB,CAAC,QAAgB;IAClD,OAAO,kBAAkB,CAAC,OAAO,CAC/B,wBAAwB,EACxB,IAAI,CAAC,SAAS,CAAC;QACb,QAAQ;KACT,CAAC,CACH,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nest-devtools",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A zero-config developer dashboard for NestJS applications.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",