lkaric / nestjs-twilio

Injectable Twilio client for Nestjs.
https://www.npmjs.com/package/nestjs-twilio
MIT License
43 stars 11 forks source link

Is there way to disable or postpone client authorization? #39

Closed r37r0m0d3l closed 2 years ago

r37r0m0d3l commented 2 years ago

On my project, I have an urgent need to delay authorization or even disable client but load the module. Perhaps there is a way to inherit from NestTwilioModule and somehow make delayed authorization? The matter is that from start I do not have accountSid and authToken to authorize.

lkaric commented 2 years ago

What do you mean by not having the accountSid and authToken from the start, can you elaborate on why and how you pull the credentials and why that is "delayed?

r37r0m0d3l commented 2 years ago

In short - application is a microservice. It's starts right away, but receive some configuration when other microservice is started. No, there is no other hacky way to do it, if you want to ask that. Even worse, I have v1.2.0, so I don't think pull request for v3.0.0 from me will help much. Another way is somehow disable module (Twilio client initialization), and then restart whole aplication when credentials is received.

lkaric commented 2 years ago

Not out of the box, I'd recommend taking a look at async providers here and/or, perhaps, lazy loading modules here. The whole package is a wrapper around the twilio SDK, and this sounds like it could be a more nest-related question. I'd be happy to try and debug if you were to provide a minimal reproduction.

The async providers could be the way to go in the case of wanting to delay the module registration.

r37r0m0d3l commented 2 years ago

I just forked version 3 and did a very neat hack for lazy client initialization with a boolean flag that client is initialized. I'm closing issue.