nestjs icon indicating copy to clipboard operation
nestjs copied to clipboard

Support for global APP_ providers

Open Morb0 opened this issue 3 years ago • 0 comments

Will be nice to add support for global providers, like that (APP_INTERCEPTOR, APP_GUARD, APP_GUARD, APP_PIPE). Now there now way to register some global providers for whole application and need to duplicate @UseInterceptor, @UseGuard decorators for every update class.

Example:

app.module.ts

import { APP_INTERCEPTOR, APP_FILTER, APP_GUARD, APP_PIPE } from '@nestjs/core';
// ...

@Module({
  // ...
  providers: [
    {
      provide: APP_INTERCEPTOR,
      useClass: ResponseTimeInterceptor,
    },
    {
      provide: APP_FILTER,
      useClass: GrammyExceptionFilter,
    },
    {
      provide: APP_GUARD,
      useClass: AdminGuard,
    },
    {
      provide: APP_PIPE,
      useClass: ReverseTextPipe,
    },
  ],
})
export class AppModule {}

Provider classes similar to these

Morb0 avatar Jul 20 '22 02:07 Morb0