Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with .forRootAsync #3

Open
benMain opened this issue Feb 4, 2021 · 5 comments
Open

Issue with .forRootAsync #3

benMain opened this issue Feb 4, 2021 · 5 comments

Comments

@benMain
Copy link
Contributor

benMain commented Feb 4, 2021

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
Copy link
Contributor Author

benMain commented Feb 4, 2021

@KerryRitter fix this!

@felinto-dev
Copy link

felinto-dev commented Mar 9, 2021

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
Copy link

felinto-dev commented Mar 10, 2021

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

@KerryRitter
Copy link
Member

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.

@geekyayush
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants