nest-endpoints
v0.1.2
Published
Zero-config NestJS route scanner with runtime metrics and dashboard.
Readme
nest-endpoints
nest-endpoints is a zero-config NestJS module that scans registered HTTP routes at bootstrap, keeps bounded in-memory request metrics, and exposes both a JSON API and a small embedded dashboard.
Install
npm install nest-endpointsPeer dependencies:
@nestjs/common@nestjs/corereflect-metadatarxjs
Usage
import { Module } from '@nestjs/common';
import { EndpointsModule } from 'nest-endpoints';
@Module({
imports: [
EndpointsModule.forRoot({
path: '_endpoints',
trackRequests: true,
auth: {
enabled: true,
username: 'admin',
password: 'secret'
},
exclude: ['/health', '/metrics']
})
]
})
export class AppModule {}By default the package exposes:
GET /_endpointsGET /_endpoints/api/routesGET /_endpoints/api/routes/:idGET /_endpoints/api/statsGET /_endpoints/api/stats/:routeIdGET /_endpoints/api/metaDELETE /_endpoints/api/stats
Config
export interface EndpointsConfig {
path?: string;
auth?: {
enabled: boolean;
username: string;
password: string;
};
exclude?: string[];
trackRequests?: boolean;
maxRequestHistory?: number;
globalPrefix?: string;
ui?: {
enabled?: boolean;
theme?: 'light' | 'dark' | 'auto';
};
}Notes
- Route scanning runs in
onApplicationBootstrapso third-party modules have time to register their controllers. - Request history is stored in a fixed-size circular buffer per route.
- The dashboard routes are registered through the active HTTP adapter so the configured
pathcan stay dynamic. - When
trackRequestsis disabled, route scanning and the JSON API still work.
