Within my NestJS application, I came across the following code snippet:
@Module({
imports: [
AnotherModule.register({
callBackUrl: 'http://localhost:3333/callback',
merchantId: '124312352134123',
currency: 'CAD',
}),
],
providers: [PaymentsService, ...PaymentsProviders],
exports: [PaymentsService],
})
export class PaymentsModule {}
When trying to access the merchantId
from global variables or a configuration module in NestJS, I found out about using useFactory
. However, this method usually works with the registerAsync
instead of just register
.
The issue here is that the AnotherModule does not have a registerAsync
method. Is there an alternative approach I can take?
My question is: why am I unable to use process.env
in this scenario? (I understand it may not be ideal when dealing with a configuration module, but I'm curious about the reason behind it)
Thank you.