alphamikle / nest_transact

Simplest transactions support for Nestjs with Typeorm
MIT License
116 stars 20 forks source link

Unable to read env variables from config service. #11

Closed armansujoyan closed 2 years ago

armansujoyan commented 2 years ago

There is a config service that I have configured to use @nestjs/config module underneath. Whenever this config service is injected, I no longer can get the config variables from the service when one of the services is inheriting from the TransactionFor class.

alphamikle commented 2 years ago

Hello @armansujoyan, you can use excluded option of method withTransaction with passing your ConfigService to it. Of course - if your ConfigService doesn't contain any methods, which must be run in the transaction and if dependencies of ConfigService don't have any same methods.

Here is an example:

// ...
await this.someService.withTransaction(transactionEntityManager, { excluded: [ConfigService] }).someFunctionWhichWillUseTransactions(payload);
// ...
alphamikle commented 2 years ago

@armansujoyan is that solve your problem?

armansujoyan commented 2 years ago

@alphamikle I tried using exclude option but it didn't work, as the reflector wasn't able to find the service within a context.

alphamikle commented 2 years ago

Well, it is strange, but maybe the ConfigService uses some kind of magic while creating and needs to investigate. Please, if you can - provide some example which describes your problem.

alphamikle commented 2 years ago

@armansujoyan, hello!

Feel free to send PR with the fix of this issue, if it is annoying for you. Unfortunately for now I don't have much time to fix specific errors.