nest-devtools
v0.1.6
Published
A zero-config developer dashboard for NestJS applications.
Readme
nest-devtools
A zero-config developer dashboard for NestJS applications.
nest-devtools mounts a browser UI inside your Nest app so you can watch logs and HTTP requests in real time while developing.
Features
- Zero-config module setup with
DevtoolsModule.forRoot() - Live logs captured from Nest
LoggerandConsoleLogger - Live HTTP request tracing with method, path, status, duration, and redacted headers
- Newest logs and requests shown first in the dashboard
- In-memory circular-style buffers for logs and requests
- Embedded dashboard UI served by your Nest app
- Raw WebSocket live updates, no frontend framework required
- Auto-disabled when
NODE_ENV === 'production'
Compatibility
- NestJS
^10.0.0 || ^11.0.0 reflect-metadata^0.1.12 || ^0.2.0rxjs^7.8.0
Install
npm i nest-devtoolsIf you are testing the package locally before publishing a new version, install it from the repo instead of npm:
npm i /absolute/path/to/nest-devtoolOr pack it first and install the generated tarball:
npm pack
npm i ./nest-devtools-0.1.3.tgzQuick Start
Import the module in your app module:
import { Module } from '@nestjs/common';
import { DevtoolsModule } from 'nest-devtools';
@Module({
imports: [DevtoolsModule.forRoot()],
})
export class AppModule {}Start your app and open:
http://localhost:3000/__devtools__That is enough for the dashboard to start collecting:
- Nest logs
- request traces
- request and response payload snapshots
- live updates through the built-in WebSocket endpoint
How It Works
At runtime, nest-devtools follows this flow:
DevtoolsModule.forRoot()is imported into your Nest app.- If
NODE_ENV === 'production', the module becomes a no-op and does nothing. - In development, the module registers:
- an in-memory store for logs and requests
- a dashboard controller
- a realtime WebSocket server
- a logger capture provider
- a global request interceptor
- The logger capture provider patches Nest's built-in
LoggerandConsoleLoggerpaths so log calls are normalized, stored in memory, and pushed to connected dashboard clients. - The request interceptor captures request details when a request enters Nest:
- method
- path
- headers
- request body
- uploaded file metadata when files are present
- The interceptor also captures the outgoing response when it is written back to the client:
- final status code
- duration
- response body
- The dashboard page loads initial snapshots from the REST API:
GET /__devtools__/api/logsGET /__devtools__/api/requests
- After that, the browser opens the built-in WebSocket endpoint and receives live updates:
logrequestclear:logsclear:requests
Body Capture Rules
- JSON, text, arrays, objects, numbers, booleans, and null values are stored when they fit within the limit.
- Request and response bodies are limited to
4kB. - If a body is larger than
4kB, the dashboard stores a note indicating that the payload was too large instead of storing the full content. - Binary payloads are not stored directly.
- For uploaded files and binary responses, the dashboard stores metadata only.
Configuration
import { Module } from '@nestjs/common';
import { DevtoolsModule } from 'nest-devtools';
@Module({
imports: [
DevtoolsModule.forRoot({
maxLogs: 500,
maxRequests: 500,
path: '__devtools__',
capture: {
logs: {
excludeLevels: ['debug'],
},
requests: {
excludeMethods: ['OPTIONS'],
},
},
}),
],
})
export class AppModule {}Options
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| maxLogs | number | 500 | Maximum number of log entries kept in memory |
| maxRequests | number | 500 | Maximum number of request entries kept in memory |
| path | string | __devtools__ | Base path used for the dashboard and API routes |
| capture | DevtoolsCaptureOptions | { logs: { enabled: true }, requests: { enabled: true } } | Global capture filters for logs and requests |
Examples:
path: '__devtools__'->/__devtools__path: '/inspect/'->/inspectpath: 'internal/devtools'->/internal/devtools
Capture Filters
import { Module } from '@nestjs/common';
import { DevtoolsModule } from 'nest-devtools';
@Module({
imports: [
DevtoolsModule.forRoot({
capture: {
logs: {
excludeLevels: ['debug', 'verbose'],
},
requests: {
excludeMethods: ['OPTIONS', 'HEAD'],
},
},
}),
],
})
export class AppModule {}capture.logs.enabled: disable log capture entirelycapture.logs.excludeLevels: skip selected Nest log levels such aslog,warn,error,debug, andverbosecapture.requests.enabled: disable request capture entirelycapture.requests.excludeMethods: skip selected HTTP methods such asOPTIONS
Ignore Decorator
Use @IgnoreDevtools() on a controller class or route handler when you do not want devtools to collect from that scope.
import { Controller, Get, Logger } from '@nestjs/common';
import { IgnoreDevtools } from 'nest-devtools';
@Controller('health')
@IgnoreDevtools({ requests: true })
export class HealthController {
private readonly logger = new Logger(HealthController.name);
@Get()
check() {
this.logger.log('health check hit');
return { ok: true };
}
@Get('silent')
@IgnoreDevtools()
silent() {
this.logger.log('this log will not be collected');
return { ok: true };
}
}@IgnoreDevtools(): ignore both logs and requests for that controller or handler@IgnoreDevtools({ logs: true }): ignore only logs@IgnoreDevtools({ requests: true }): ignore only requests
How To Use It
Once your Nest app is running:
- Open the dashboard URL in your browser.
- Hit your normal API routes from Postman, your frontend, curl, or the browser.
- Watch logs and requests appear live in the dashboard.
Logs Tab
- Shows
log,warn,error,debug, andverbose - Shows the newest log entry first
- Includes timestamp, level, context, and message
- Supports client-side search and level filters
- Can be cleared from the UI
Requests Tab
- Shows timestamp, method, path, status, and duration
- Shows the newest request first
- Streams requests live as they finish
- Lets you filter by HTTP method and status range
- Expands each row to show the full path, headers, request body, and response body
- Long paths are truncated in the table so they do not break the layout
What Gets Captured
Logs
The package captures logs that go through Nest's built-in logging path:
Logger.log()Logger.warn()Logger.error()Logger.debug()Logger.verbose()- direct
ConsoleLoggerusage
Requests
The package captures HTTP requests handled by Nest and stores:
- method
- path
- status code
- duration in milliseconds
- timestamp
- optional request headers
- request body snapshot
- response body snapshot
- uploaded file metadata when present
Request and response body behavior:
- bodies up to
4kBare stored - bodies larger than
4kBare replaced with a "payload too large" note - binary content is omitted from storage
- file uploads and binary responses keep metadata only
Sensitive headers are redacted:
authorizationcookieset-cookieproxy-authorizationx-api-key
Routes
With the default path, the module exposes:
| Method | Path | Description |
| --- | --- | --- |
| GET | /__devtools__ | Dashboard UI |
| GET | /__devtools__/api/logs | Current log buffer |
| GET | /__devtools__/api/requests | Current request buffer |
| DELETE | /__devtools__/api/logs | Clear logs |
| DELETE | /__devtools__/api/requests | Clear requests |
| WS | /__devtools__/ws | Live realtime stream |
Production Behavior
If NODE_ENV === 'production', DevtoolsModule.forRoot() becomes a no-op:
- no dashboard route
- no API endpoints
- no request interceptor
- no logger patching
- no WebSocket listener
Notes
- Everything is in memory only.
- The dashboard does not persist data across restarts.
- The dashboard skips recording its own requests to avoid self-noise.
- This package is intended for development, not production monitoring.
Example App In This Repo
Run the included example app:
npm install
npm run example:startThen open:
http://localhost:3000/__devtools__Useful example routes:
GET /GET /users/123GET /warnGET /fail
Development
npm install
npm run build
npm test