nest-aws-sdk icon indicating copy to clipboard operation
nest-aws-sdk copied to clipboard

Issue with .forRootAsync

Open benMain opened this issue 4 years ago • 5 comments

During module initialization, if I provide serviceProviders but not the optional defaultServiceOptions the code returns before adding my serviceProviders to the Providers and exports of the dynamic modules

benMain avatar Feb 04 '21 15:02 benMain

@KerryRitter fix this!

benMain avatar Feb 04 '21 15:02 benMain

Try it

@Module({
  imports: [
    AwsSdkModule.forRootAsync({
      defaultServiceOptions: {
        inject: [ConfigService],
        useFactory: (configService) => ({
          credentials: {
            accessKeyId: configService.get('scaleway.ACCESS_KEY_ID'),
            secretAccessKey: configService.get('scaleway.SECRET_ACCESS_KEY'),
          },
          region: configService.get('scaleway.REGION'),
          endpoint: configService.get('scaleway.ENDPOINT'),
        }),
      },
      services: [S3],
    }),
  ],
})

PS: Double-check for import "configService" from "@nestjs/config"

(just an example config)

felinto-dev avatar Mar 09 '21 21:03 felinto-dev

After a lot of headaches with this plugin and others that propose to be a wrapper between nestjs and aws-sdk, I decided to configure the dependency injection by myself and the result was not bad.

https://gist.github.com/felinto-dev/0450a3484ddd8aefefc79f42797eeadf

felinto-dev avatar Mar 10 '21 10:03 felinto-dev

After a lot of headaches with this plugin and others that propose to be a wrapper between nestjs and aws-sdk, I decided to configure the dependency injection by myself and the result was not bad.

https://gist.github.com/felinto-dev/0450a3484ddd8aefefc79f42797eeadf

Sorry to hear you had problems. Are your issues related to what @benMain posted? Looks like you supply the default options.

That said, your solution is how I would approach the problem without nest-aws-sdk.

KerryRitter avatar Mar 10 '21 13:03 KerryRitter

After a lot of headaches with this plugin and others that propose to be a wrapper between nestjs and aws-sdk, I decided to configure the dependency injection by myself and the result was not bad.

https://gist.github.com/felinto-dev/0450a3484ddd8aefefc79f42797eeadf

Thank you so much @felinto-dev for the code snippet. I have been facing some issues while using the library. I was getting the following error:

Potential solutions:
- If S3ManagerService is a provider, is it part of the current DocumentModule?
- If S3ManagerService is exported from a separate @Module, is that module imported within DocumentModule?
  @Module({
    imports: [ /* the Module containing S3ManagerService */ ]
  })

But now, using your method, worked for me.

geekyayush avatar Dec 17 '22 08:12 geekyayush