@nestjs/core#APP_INTERCEPTOR TypeScript Examples
The following examples show how to use
@nestjs/core#APP_INTERCEPTOR.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: app.module.template.ts From amplication with Apache License 2.0 | 6 votes |
@Module({
controllers: [],
imports: MODULES,
providers: [
{
provide: APP_INTERCEPTOR,
scope: Scope.REQUEST,
useClass: MorganInterceptor("combined"),
},
],
})
export class AppModule {}
Example #2
Source File: module.ts From test with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Module({
imports: [
GraphQLModule.forRoot({
introspection: Boolean(playground),
playground,
installSubscriptionHandlers: false,
autoSchemaFile: 'schema.gql',
path: '//',
cors: false,
context: ({ req }) => ({
user: req.get('x-user'),
}),
}),
IdentityModule,
],
providers: [
{
provide: APP_INTERCEPTOR,
useClass: DataLoaderInterceptor,
},
],
})
export class ApplicationModule {}
Example #3
Source File: tracing.module.ts From nestjs-jaeger-tracing with MIT License | 6 votes |
static forRoot(options: TracingModuleOptions): DynamicModule {
const providers: Provider[] = [];
TracingModule.tracerProvider = TracerProvider.getInstance(options);
TracingModule.tracer = TracingModule.tracerProvider.getTracer();
const optionsProvider: Provider<TracingModuleOptions> = {
provide: TRACING_MODULE_OPTIONS,
useValue: options,
};
const tracerProvider: Provider = {
provide: TRACER,
useValue: TracingModule.tracer,
};
const tracerProviderFactory: Provider = {
provide: TRACER_PROVIDER,
useValue: TracingModule.tracerProvider,
};
providers.push(optionsProvider);
providers.push(tracerProvider);
providers.push(tracerProviderFactory);
return {
module: TracingModule,
providers: [
...providers,
{
provide: APP_INTERCEPTOR,
useClass: TracingInterceptor,
},
],
exports: [...providers],
};
}
Example #4
Source File: tracing.module.ts From nestjs-jaeger-tracing with MIT License | 6 votes |
static forRootAsync(options: TracingModuleAsyncOptions): DynamicModule {
const asyncProviders: Provider[] = [];
const tracerProviderFactory: Provider = {
provide: TRACER_PROVIDER,
useFactory: (tracingOptions: TracingModuleOptions) => {
TracingModule.tracerProvider = TracerProvider.getInstance(
tracingOptions,
);
return TracingModule.tracerProvider;
},
inject: [TRACING_MODULE_OPTIONS],
};
const tracerProvider: Provider = {
provide: TRACER,
useFactory: (tracingProvider: TracerProvider) => {
TracingModule.tracer = tracingProvider.getTracer();
return TracingModule.tracer;
},
inject: [TRACER_PROVIDER],
};
asyncProviders.push(tracerProvider);
asyncProviders.push(tracerProviderFactory);
asyncProviders.push(...TracingModule.createAsyncProvider(options));
return {
module: TracingModule,
providers: [
...asyncProviders,
{
provide: APP_INTERCEPTOR,
useClass: TracingInterceptor,
},
],
exports: [...asyncProviders],
};
}
Example #5
Source File: datadog.module.ts From ironfish-api with Mozilla Public License 2.0 | 6 votes |
@Module({
exports: [DatadogService],
imports: [ApiConfigModule],
providers: [
DatadogService,
{
provide: APP_INTERCEPTOR,
useClass: DatadogInterceptor,
},
],
})
export class DatadogModule {}
Example #6
Source File: shared.module.ts From mamori-i-japan-api with BSD 2-Clause "Simplified" License | 6 votes |
@Module({
imports: [ConfigModule.forRoot(configModuleOptions), FirebaseModule, LoggerModule],
providers: [
{ provide: APP_INTERCEPTOR, useClass: LoggingInterceptor },
{
provide: APP_FILTER,
useClass: AllExceptionsFilter,
},
],
exports: [ConfigModule, FirebaseModule, LoggerModule],
})
export class SharedModule {}
Example #7
Source File: shared.module.ts From nestjs-starter-rest-api with MIT License | 6 votes |
@Module({
imports: [
ConfigModule.forRoot(configModuleOptions),
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
type: 'mysql',
host: configService.get<string>('database.host'),
port: configService.get<number | undefined>('database.port'),
database: configService.get<string>('database.name'),
username: configService.get<string>('database.user'),
password: configService.get<string>('database.pass'),
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
// Timezone configured on the MySQL server.
// This is used to typecast server date/time values to JavaScript Date object and vice versa.
timezone: 'Z',
synchronize: false,
debug: configService.get<string>('env') === 'development',
}),
}),
AppLoggerModule,
],
exports: [AppLoggerModule, ConfigModule],
providers: [
{ provide: APP_INTERCEPTOR, useClass: LoggingInterceptor },
{
provide: APP_FILTER,
useClass: AllExceptionsFilter,
},
],
})
export class SharedModule {}
Example #8
Source File: shared.module.ts From Phantom with MIT License | 6 votes |
@Module({
imports: [
MongooseModule.forFeature([
{ name: 'User', schema: User },
{ name: 'Pin', schema: Pin },
{ name: 'Board', schema: Board },
{ name: 'Topic', schema: Topic },
{ name: 'Message', schema: Message },
{ name: 'Chat', schema: Chat },
]),
],
providers: [
SharedGateway,
ChatService,
ValidationService,
Email,
NotificationService,
{
provide: APP_FILTER,
useClass: HttpExceptionFilter,
},
{
provide: APP_INTERCEPTOR,
useClass: LoggingInterceptor,
},
],
exports: [NotificationService, ValidationService, Email],
})
export class SharedModule { }
Example #9
Source File: app.module.ts From amplication with Apache License 2.0 | 5 votes |
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
envFilePath: ['.env.local', '.env']
}),
SendGridModule.forRootAsync({
imports: [ConfigModule, GoogleSecretsManagerModule],
inject: [ConfigService, GoogleSecretsManagerService],
useClass: SendgridConfigService
}),
ServeStaticModule.forRoot({
rootPath: path.join(
__dirname,
'..',
'..',
'..',
'amplication-client',
'build'
),
exclude: ['/graphql']
}),
RootWinstonModule,
GraphQLModule.forRootAsync({
useFactory: async (configService: ConfigService) => ({
autoSchemaFile:
configService.get('GRAPHQL_SCHEMA_DEST') || './src/schema.graphql',
debug: configService.get('GRAPHQL_DEBUG') === '1',
playground: configService.get('PLAYGROUND_ENABLE') === '1',
context: ({ req }: { req: Request }) => ({
req
})
}),
inject: [ConfigService]
}),
RootStorageModule,
MorganModule,
SegmentAnalyticsModule.registerAsync({
useClass: SegmentAnalyticsOptionsService
}),
CoreModule
],
controllers: [],
providers: [
{
provide: APP_INTERCEPTOR,
useClass: InjectContextInterceptor
}
]
})
export class AppModule implements OnApplicationShutdown {
onApplicationShutdown(signal: string) {
console.trace(`Application shut down (signal: ${signal})`);
}
}
Example #10
Source File: shared.module.ts From radiopanel with GNU General Public License v3.0 | 4 votes |
@Module({
imports: [
TypeOrmModule.forFeature([
Tenant,
SlotOverwrite,
User,
UserRole,
Role,
RolePermission,
Webhook,
AuditLog,
ApiKey,
ApiKeyPermission,
ApiKeyUsage,
Slot,
UserMeta,
Ban,
UserPermission,
AuthenticationMethod,
ContentType,
PageType,
ContentTypeField,
PageTypeField,
Content,
Page
]),
ConfigModule
],
providers: [
...Helpers,
...Guards,
// Services
TenantService,
UserService,
RoleService,
WebhookService,
AuditLogService,
ApiKeyService,
SlotService,
PermissionService,
BanService,
AuthMethodService,
ContentTypeService,
PageTypeService,
PopulationService,
// Interceptors
{
provide: APP_INTERCEPTOR,
useClass: WebhookInterceptor,
},
{
provide: APP_INTERCEPTOR,
useClass: AuditLogInterceptor,
},
],
exports: [
...Helpers,
...Guards,
// Services
TenantService,
UserService,
RoleService,
WebhookService,
AuditLogService,
ApiKeyService,
SlotService,
PermissionService,
BanService,
AuthMethodService,
ContentTypeService,
PageTypeService,
PopulationService,
// Modules
ConfigModule,
]
})
export class SharedModule {}