Closed eladabramovich closed 6 months ago
Basically you want the SDK to be an injectable? and to have the guard as "given"?
sounds great. go for it ! 🚀
You are correct about the SDK being injectable. Not sure about what you meant by "given"
but basically, the SDK will be instantiated in a service that the new module will export
and I will add an optional defaultErrorMessage
property to PriciSDKOptions
(for cases
where the user wants one default message for all routes that is not "payment required").
With these 2 changes, the guard doesn't have any required options anymore and can be reduced to:
@UseGuards(IsAllowedGuard())
P.S I was able to implement the guard in a slightly different way that doesn't require
invoking it with the new
keyword
Currently, when creating a new Prici SDK instance in a NestJs app the app does not know about the SDK instance in any way. This means that the SDK does not work in tandem with the Nest runtime. By abstracting the SDK instance in a custom module, the following could be achieved:
@nestjs/config
and possibly other Nest related packages in the future.