Import StripeModule via forRootAsync useFactory configuration
See original GitHub issueI’m trying to configure the StripeModule
via factory method to use ConfigService
instead of direct access to process.env
const configuration = {
// ...
stripe: {
apikey: process.env.STRIPE_APIKEY,
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
},
}
@Module({
imports: [
ConfigModule.forRoot({ validationSchema, isGlobal: true, load: [configuration] }),
StripeModule.forRootAsync(StripeModule, {
imports: [StripeModule],
inject: [ConfigService],
useFactory: async (config: ConfigService) => ({
apiKey: config.get('stripe.apikey', ''),
webhookConfig: {
stripeWebhookSecret: config.get('stripe.webhookSecret', ''),
},
}),
}),
],
controllers: [PaymentsController],
providers: [PaymentsService],
})
export class PaymentsModule {}
At runtime I get the following error:
[Nest] 160071 - 10/22/2021, 6:59:39 PM ERROR [ExceptionHandler] Nest can't resolve dependencies of the StripeModule (DiscoveryService, ExternalContextCreator, ?). Please make sure that the argument Symbol(STRIPE_MODULE_CONFIG_TOKEN) at index [2] is available in the StripeModule context.
Potential solutions:
- If Symbol(STRIPE_MODULE_CONFIG_TOKEN) is a provider, is it part of the current StripeModule?
- If Symbol(STRIPE_MODULE_CONFIG_TOKEN) is exported from a separate @Module, is that module imported within StripeModule?
@Module({
imports: [ /* the Module containing Symbol(STRIPE_MODULE_CONFIG_TOKEN) */ ]
})
Error: Nest can't resolve dependencies of the StripeModule (DiscoveryService, ExternalContextCreator, ?). Please make sure that the argument Symbol(STRIPE_MODULE_CONFIG_TOKEN) at index [2] is available in the StripeModule context.
Potential solutions:
- If Symbol(STRIPE_MODULE_CONFIG_TOKEN) is a provider, is it part of the current StripeModule?
- If Symbol(STRIPE_MODULE_CONFIG_TOKEN) is exported from a separate @Module, is that module imported within StripeModule?
@Module({
imports: [ /* the Module containing Symbol(STRIPE_MODULE_CONFIG_TOKEN) */ ]
})
at Injector.lookupComponentInParentModules (../node_modules/@nestjs/core/injector/injector.js:193:19)
I’m trying the see if I’m missing a piece of configuration or the only way to register the module is via forRoot()
method
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Adding the module in async mode not working #93 - GitHub
Bug reports: Facing issue while adding the module in Async mode import { StripeModule } from 'nestjs-stripe'; import { ConfigModule, ...
Read more >nestjs-stripe - npm
Start using nestjs-stripe in your project by running `npm i nestjs-stripe`. ... StripeModule , which when imported into your nestjs project ...
Read more >Provides an injectable Stripe Client to Nestjs Modules - Morioh
nestjs-stripe implements a module, StripeModule, which when imported into your ... forRootAsync({ inject: [ConfigService], useFactory: (configService: ...
Read more >@ntegral/nestjs-sendgrid - npm package | Snyk
Ensure you're using the healthiest npm packages ... forRootAsync({ imports: [ConfigModule], useFactory: async (cfg:ConfigService) => ({ apiKey: ...
Read more >argument of type 'typeof configservice' is not assignable to ...
forRootAsync with useFactory and postgres connection settings ... and this is my auth module ` import { StripeModule } from 'nestjs-stripe';.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you for your help! I kept experimenting and I made another stupid mistake. In a different module I imported the Golevelup StripeModule instead of my custom module. That threw the error.
You shouldn’t put StripeModule in the imports array of itself
On Fri., Oct. 22, 2021, 12:07 p.m. Ilko Kacharov, @.***> wrote: