nestjs / azure-storage

Azure Storage module for Nest framework (node.js) ☁️
https://nestjs.com
MIT License
87 stars 35 forks source link

Using AzureStorageModule in different modules overrides one another's config #325

Closed andre1ka-ber closed 8 months ago

andre1ka-ber commented 1 year ago

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I am using AzureStorageModule.withConfigAsync() in different modules with different config, which includes SAS, storage account and default container name and then injecting AzureStorageService in providers section. So all services (in my case 2) contains same config. And a small note, second module using config of first module in list order in app.module.ts, if I change that order, config will be changed as well

imagine two module's options as below, the only difference is config in useFactory field

@Module({
    imports: [
      AzureStorageModule.withConfigAsync({
          useFactory: firstAzureConfig, // <-- in second module another config
          inject: [ConfigService],
      }),
    ], 
    providers: [
      {
          provide: AzureImagesStorageClient,
          useFactory: (azureService: AzureStorageService) => {
            console.log(azureService); // <-- here I see same configuration
            return new AzureImagesStorageClient(azureService);
          },
          inject: [AzureStorageService],
        }
    ]

image

Expected behavior

I expect that each module should contain its configuration and one should not override another one

Environment


Nest version: 10.2.10


For Tooling issues:
- Node version: v18.13.0
- Platform:  Linux
kamilmysliwiec commented 8 months ago

Let's track this here https://github.com/nestjs/nest/pull/13336