nest-profiler-routes
Types and API of the Routes panel and its route-source extension point.
RoutesCollectorModuleOptions
Options passed to RoutesCollectorModule.forRoot().
Prop
Type
What is captured
At application startup the panel discovers every registered route, grouped by transport. The package ships a built-in REST source; other transport packages contribute their own group when installed:
- REST (built-in) — every
@Controllerhandler, with its HTTP method, full path and the inputs read from@Param,@Query,@Headersand@Body. - GraphQL — every query, mutation and subscription field with its argument names (
@eleven-labs/nest-profiler-graphql). - RabbitMQ — every
@RabbitSubscribeconsumer with its exchange, routing key and handler (@eleven-labs/nest-profiler-rabbitmq). - Commands — every nest-commander
@Command()with its name and--optionflags (@eleven-labs/nest-profiler-commander).
A REST route also shows the guards protecting it — the classes from @UseGuards() on the controller and/or handler (e.g. an authentication guard) — with a lock marking guarded routes. Only route-level guards are reflected; a global APP_GUARD is not attached per handler.
For a REST route, each @Body() DTO is introspected to its top-level decorated properties: the property name, its TypeScript type and, when class-validator is installed, the validation rules. Introspection is top-level only — a property that is itself a DTO surfaces as its class name rather than being expanded.
Public exports
import {
RoutesCollectorModule,
RoutesCollector,
HttpRouteSource,
describeHandlerParams,
} from '@eleven-labs/nest-profiler-routes';
import type {
RoutesCollectorModuleOptions,
RoutesCollectorModuleAsyncOptions,
RoutesCollectorData,
} from '@eleven-labs/nest-profiler-routes';The ProfilerRouteSource, RouteGroup, RouteEntry and RouteInputs types — the extension point every source implements — are exported from the core package:
import type {
ProfilerRouteSource,
RouteGroup,
RouteEntry,
RouteInputs,
} from '@eleven-labs/nest-profiler';Setup
// In AppModule:
import { ConditionalModule } from '@nestjs/config';
import { RoutesCollectorModule } from '@eleven-labs/nest-profiler-routes';
const isProfilerEnabled = (env: NodeJS.ProcessEnv) => env['PROFILER_ENABLED'] === 'true';
ConditionalModule.registerWhen(RoutesCollectorModule.forRoot(), isProfilerEnabled);Contributing a custom route source
Register a ProfilerRouteSource with the core to add your own group to the panel — the same mechanism the GraphQL, RabbitMQ and CLI packages use. Resolve the core via ModuleRef (a dynamic module cannot reliably inject a provider exported by another dynamic module):
import { Injectable, OnApplicationBootstrap } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { ProfilerCoreService } from '@eleven-labs/nest-profiler';
import type { ProfilerRouteSource, RouteGroup } from '@eleven-labs/nest-profiler';
@Injectable()
export class MyRouteSource implements ProfilerRouteSource, OnApplicationBootstrap {
readonly type = 'my-transport';
constructor(private readonly moduleRef: ModuleRef) {}
onApplicationBootstrap(): void {
try {
this.moduleRef.get(ProfilerCoreService, { strict: false }).registerRouteSource(this);
} catch {
// profiler not configured — nothing to register with
}
}
collect(): RouteGroup {
return { source: 'my-transport', label: 'My transport', routes: [] };
}
}