NestJS Profiler
Packages

nest-profiler-routes

Inspect the application routing table in a Symfony-Routing-style Routes panel.

@eleven-labs/nest-profiler-routes

@eleven-labs/nest-profiler-routes adds a Routes panel to the profiler home page — a Symfony-Routing-style view of the application's routing table. Every registered route is listed with its HTTP method, full path and controller/handler; a lock marks routes protected by a guard. Expanding a route reveals its guards, path params, query params, request headers, and the body DTO (class name, decorated properties, TypeScript types and, when class-validator is installed, the validation rules).

Routes view — the application routing table grouped by transport (REST, GraphQL, RabbitMQ, Commands), with per-route inputs, body DTOs and a lock on guarded routes

Installation

pnpm add @eleven-labs/nest-profiler-routes@alpha

There is no stable release yet — install every @eleven-labs/nest-profiler* package with the @alpha dist-tag (@latest resolves to nothing).

Peer dependencies: @eleven-labs/nest-profiler. class-validator is an optional peer — install it to surface DTO properties and validation rules; without it, a body DTO shows only its class name.

Setup

app.module.ts
import { ConditionalModule } from '@nestjs/config';
import { RoutesCollectorModule } from '@eleven-labs/nest-profiler-routes';

const isProfilerEnabled = (env: NodeJS.ProcessEnv) => env['PROFILER_ENABLED'] === 'true';

@Module({
  imports: [ConditionalModule.registerWhen(RoutesCollectorModule.forRoot(), isProfilerEnabled)],
})
export class AppModule {}

Enabling / disabling — gate the collector with ConditionalModule.registerWhen(..., isProfilerEnabled) so it loads only when the profiler is on, or pass RoutesCollectorModule.forRoot({ enabled: false }). Wire the core ProfilerModule once at the root (add its ProfilerNoopModule fallback only if you inject ProfilerService directly) — see the example app.

What it collects

At application startup, the panel discovers every registered route and groups it by transport. The core ships a built-in REST source; other transport packages contribute their own group — GraphQL resolvers (@eleven-labs/nest-profiler-graphql), RabbitMQ subscribers (@eleven-labs/nest-profiler-rabbitmq) and CLI commands (@eleven-labs/nest-profiler-commander) — by registering a ProfilerRouteSource with the core, so they appear automatically when installed.

Each REST route is introspected from its decorator metadata:

  • Guards — the guard classes from @UseGuards() on the controller and/or handler (e.g. an authentication guard); guarded routes show a lock. Only route-level guards are visible — a global APP_GUARD is not attached per handler.
  • Path params — from the route path (/users/:idid).
  • Query params — from @Query('name') and whole-object @Query() DTOs.
  • Headers — from @Headers('name').
  • Body DTO — from @Body(): the DTO class name, its top-level decorated properties with their TypeScript types, and (with class-validator) the validation rules per property.

Introspection is top-level only: a property that is itself a DTO surfaces as its class name rather than being expanded.

Contributing a custom route source

Any package can add its own group to the panel by registering a ProfilerRouteSource with the core (mirroring how entrypoint types are registered):

import { ModuleRef } from '@nestjs/core';
import { ProfilerCoreService } from '@eleven-labs/nest-profiler';
import type { ProfilerRouteSource } from '@eleven-labs/nest-profiler';

// in a module lifecycle hook:
const core = this.moduleRef.get(ProfilerCoreService, { strict: false });
core.registerRouteSource(mySource satisfies ProfilerRouteSource);

License

MIT © Eleven Labs

Powered & maintained by

On this page