@@ -39,38 +39,28 @@ export class ReporterModule {
3939 } ;
4040 }
4141
42- static async forRootAsync ( options : ReporterAsyncOptions ) : Promise < DynamicModule > {
43- const providers : Provider [ ] = [
44- {
45- provide : CONFIG_OPTIONS ,
46- useFactory : options . useFactory ,
47- inject : options . inject ,
48- } ,
49- {
50- provide : Registry ,
51- useFactory : async ( config : MetricsConfig ) => {
52- return ReporterModule . configureRegistry ( config ) ;
53- } ,
54- inject : [ CONFIG_OPTIONS ] ,
55- } ,
56- MetricsService ,
57- ReporterService
58- ] ;
59-
60- const asyncConfig = await options . useFactory ( ...( options . inject || [ ] ) ) ;
61- if ( asyncConfig . interceptors ) {
62- providers . push ( ...asyncConfig . interceptors . map ( interceptor => ( {
63- provide : APP_INTERCEPTOR ,
64- useClass : interceptor as Type < any > ,
65- } ) ) ) ;
66- }
67-
42+ static forRootAsync ( options : ReporterAsyncOptions ) : DynamicModule {
6843 return {
6944 module : ReporterModule ,
7045 imports : options . imports ,
71- providers,
72- controllers : [ MetricsController ] ,
73- exports : [ ReporterService ]
46+ providers : [
47+ {
48+ provide : CONFIG_OPTIONS ,
49+ useFactory : options . useFactory ,
50+ inject : options . inject ,
51+ } ,
52+ {
53+ provide : Registry ,
54+ useFactory : async ( config : MetricsConfig ) => {
55+ return ReporterModule . configureRegistry ( config ) ;
56+ } ,
57+ inject : [ CONFIG_OPTIONS ] ,
58+ } ,
59+ MetricsService ,
60+ ReporterService
61+ ] ,
62+ controllers : [ MetricsController ] ,
63+ exports : [ ReporterService ]
7464 } ;
7565 }
7666
0 commit comments