I was checking one of the nestjs module's source code (nestjs-firebase-admin) and I saw something weird. In this line:
private static createProviders(app: admin.app.App): Provider<any>[] {
return PROVIDERS.map<Provider>((ProviderService) => ({
provide: ProviderService,
// here, instantiate each service class
useFactory: () => new ProviderService(app),
}));
}
Why do they instantiate each service class? This should be handled by nest core. As I know we just instantiate plain js classes when wrapping up another native plugin. But these are nestjs services. So we should not instantiate them manually. Any idea?
Note: PROVIDERS
defined as (all of them are services):
const PROVIDERS = [
FirebaseAuthenticationService,
FirebaseMessagingService,
FirebaseRemoteConfigService,
FirebaseDatabaseService,
FirebaseFirestoreService,
FirebaseStorageService,
];