nest-profiler-typeorm
Types and API of the TypeORM query collector.
TypeOrmCollectorModuleOptions
Options passed to TypeOrmCollectorModule.forRoot().
Prop
Type
QueryEntry
One entry per SQL query executed during a request.
Prop
Type
QueryType
type QueryType = 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' | 'OTHER';Detected from the first keyword of the SQL string.
Public exports
import { TypeOrmCollectorModule } from '@eleven-labs/nest-profiler-typeorm';
import { TypeOrmCollector } from '@eleven-labs/nest-profiler-typeorm';
import { TypeOrmSchemaCollectorModule } from '@eleven-labs/nest-profiler-typeorm';
import { TypeOrmSchemaCollector } from '@eleven-labs/nest-profiler-typeorm';
import type {
TypeOrmCollectorModuleOptions,
TypeOrmCollectorModuleAsyncOptions,
TypeOrmSchemaCollectorModuleOptions,
TypeOrmSchemaCollectorModuleAsyncOptions,
QueryEntry,
QueryType,
} from '@eleven-labs/nest-profiler-typeorm';Setup
// In the dev-only profiling bundle's imports:
TypeOrmCollectorModule.forRoot({
slowThreshold: 50, // ms — queries at/above this are tagged 'slow'
});Prerequisite: TypeOrmModule.forRoot() must be registered in the application (provides DataSource globally via @InjectDataSource()). The collector resolves it by token, so it needs no wiring in the module that uses TypeORM; pass connectionName for a named DataSource.
ProfilingModuleis the dev-only bundle loaded bymain-dev.ts— see Enabling and disabling the profiler. If the profiler is installed as a production dependency behind the runtime gate, wrap the same call inConditionalModule.registerWhen(..., isProfilerEnabled).
Async setup
Drive the options from ConfigService (or any provider) with forRootAsync(), registered in the same bundle. It resolves option values only — for the enabled flag and when to prefer forRoot, see Enabling and disabling the profiler.
import { ConfigService } from '@nestjs/config';
import { TypeOrmCollectorModule } from '@eleven-labs/nest-profiler-typeorm';
TypeOrmCollectorModule.forRootAsync({
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
slowThreshold: config.get<number>('PROFILER_SLOW_QUERY_MS') ?? 50,
}),
});