Would be very interesting to know more about creating custom modules, especially ones that can be registered async with the ability to inject ConfigService or sth. 🥰
I know it’s been while since you had this video done. But the ideia of using the dynamic module wouldn’t be to inject different type of tokens and instead of naming StripeModule would be something like paymentMethodProvider ? Then we can inject whatever or am I wrong ? Is it more like a strategy method? Thanks you so much.
Hey man i am currently working on a project with nest js , ts and graphql code first approach , do you have any idea on how to do file uploads . Please let me know it would be really helpful.
When we use dynamic module it also mean not a Singletons anymore right? Everytime when a module need that it have to call forRoot, so it will generate a new instance everytime, am I right? we manually instantiate provider class and pass it by value.
Thanks for the comment! All that's needed is to add the @Global() decorator to the StripeModule class. This will tell Nest to make any exports globally available. Note that you should still avoid using global modules wherever possible, since it can be hard to track down where they're used afterwards.
@@hmilbradt Q: "what if we don't want the Stripe module to be global?" A: "All that's needed is to add the @Global() decorator to the StripeModule class." "Just add that @Global() and don't ask questions" 🤣
Using the same pattern in this video, all you need to do is replace Stripe with another NPM package. The pattern works for 3rd party code, npm modules, and even your own code!
It depends, but as a general rule: yes. The example shown here is a simple one, but I will also usually write a thin wrapper service and export that instead. The biggest benefit, aside from the myriad of benefits that dependency injection brings, is that all the code that uses the library is in one place. If I ever need to upgrade my dependency, or switch to a new one, it’s all in one file and is easy to replace. Hope that helps!
@@hmilbradt using Stripe as an example, in a real world project would you still name the module “stripe”? Or would it be more advantageous to name it something like “payment_platform”, so if you do change dependencies and use something other than stripe, you don’t have to rename things and redo implementations?
I have made this implementation, but I honestly don't know how can you mock this? I'm running iunto this problem when I do jest.doMock("stripe", and all the rest and is never actually mocking stripe, is always trying to set the real instance! anyone can help with that?
Hey there Rafael, thanks for the comment! In my experience, Jest can be a bit fiddly when trying to mock imports, so I'd highly recommend opening a question on StackOverflow with some details on your setup. You could also take a look at the Jest docs, or this SO post: stackoverflow.com/questions/66368006/mock-stripe-apis-using-jest-in-node
Very underrated video. Thanks man, your way of explaining is great!
This is very clear and thorough tutorial.
I'd definitely buy a NestJS course if you make one.
Thank you so much for making videos about more advanced Nest-topics. Subscribed and hoping for more! 🙂
Thank you for this video which I exactly was looking for. That is a clear, nice, and simple example. 👌
This is a very good video and a very simple explanation thx man
Super helpful video for someone who's new to NestJS. Thanks a bunch!
Thank you for that video - exactly what I was looking for. Very clear explanation ❤️
Would be very interesting to know more about creating custom modules, especially ones that can be registered async with the ability to inject ConfigService or sth. 🥰
I know it’s been while since you had this video done.
But the ideia of using the dynamic module wouldn’t be to inject different type of tokens and instead of naming StripeModule would be something like paymentMethodProvider ? Then we can inject whatever or am I wrong ? Is it more like a strategy method?
Thanks you so much.
Can we use this dynamic strip module to other project and how?
Thanks for the tutorial! It was very helpful!
Hey man i am currently working on a project with nest js , ts and graphql code first approach , do you have any idea on how to do file uploads . Please let me know it would be really helpful.
this is gold, thanks for sharing
When we use dynamic module it also mean not a Singletons anymore right? Everytime when a module need that it have to call forRoot, so it will generate a new instance everytime, am I right?
we manually instantiate provider class and pass it by value.
Nice video bro, it helped me a lot, thank you!
Thanks man 👍👍👍 that helped a lot 🔥🔥💥
This is helpful for me ❤
Need more video on Nest.js microservices and deployment of docker image on AWS and kubernetes stuff
nice, and thank you.
Nice video. What if we dont want the stripe module to be global. Can I just import it in appmodule and reexport it? I tried but failed
Thanks for the comment! All that's needed is to add the @Global() decorator to the StripeModule class. This will tell Nest to make any exports globally available.
Note that you should still avoid using global modules wherever possible, since it can be hard to track down where they're used afterwards.
@@hmilbradt
Q: "what if we don't want the Stripe module to be global?"
A: "All that's needed is to add the @Global() decorator to the StripeModule class."
"Just add that @Global() and don't ask questions" 🤣
Thank you sir .please how to create a custom provider of a node npm package to use it in a nestjs project? thank you in advance
Using the same pattern in this video, all you need to do is replace Stripe with another NPM package. The pattern works for 3rd party code, npm modules, and even your own code!
@@hmilbradt Thank you very much Sir
very helpful
Thank you 😊
You're welcome 😊
Can you make a complete video about Stripe and nest js? that would help
I can definitely look into it. What would you like to see covered in it?
Great. For example how to integrate Stripe in nestJs and how to make endpoints for Stripe payments and send to the frontEnd
Please do make more video on nestjs Advance Topic.
Great video!
thanks, well explained
do you create modules for all the packages you install for the projects ?
It depends, but as a general rule: yes. The example shown here is a simple one, but I will also usually write a thin wrapper service and export that instead.
The biggest benefit, aside from the myriad of benefits that dependency injection brings, is that all the code that uses the library is in one place. If I ever need to upgrade my dependency, or switch to a new one, it’s all in one file and is easy to replace.
Hope that helps!
@@hmilbradt using Stripe as an example, in a real world project would you still name the module “stripe”? Or would it be more advantageous to name it something like “payment_platform”, so if you do change dependencies and use something other than stripe, you don’t have to rename things and redo implementations?
I have made this implementation, but I honestly don't know how can you mock this? I'm running iunto this problem when I do jest.doMock("stripe", and all the rest and is never actually mocking stripe, is always trying to set the real instance! anyone can help with that?
Hey there Rafael, thanks for the comment! In my experience, Jest can be a bit fiddly when trying to mock imports, so I'd highly recommend opening a question on StackOverflow with some details on your setup. You could also take a look at the Jest docs, or this SO post: stackoverflow.com/questions/66368006/mock-stripe-apis-using-jest-in-node
@@hmilbradt thanks for the reply!
Thank you
Implementation is bit messy I guess but great work