i would highly suggest to use nx, instead of the nest monorepos, as it offers a wide variety of different plugins (i.e., also allows to host react, angular, ... apps within the monorepository)
Thank you so much for sharing the knowledge i would suggest if you could make a seperate vedio explaining nestjs microservices because thats something i want to learn and you are my go to option for nestjs tutorials 😂
Thank you for the content, Sir. Also, could you explain more about migrations in Nestjs monorepo? I'm using TypeOrm and I haven't figured out what is the best practice since when I build each app, Nestjs use webpack and bundles the codes into one file only.
Very helpful, as always. I love the NestJS content. Building on this example, I'd like to see what a devcontainer would look like. To deploy to k8s, would you publish a separate image for each app? At what point would you think about adding nx?
There are some challenges with using docker on a monorepo, if you plan to do that honestly you would be better off just using turborepo or nx which likely would offer much better support for it. For example here’s some docs from turborepo that talks about some of the challenges and how you’d solve it: turbo.build/repo/docs/handbook/deploying-with-docker Not very familiar with nx yet, but in general I think any setup that’s slightly more complex than what I show here is probably worth switching over. Also if you think you’d mix other types of applications into your monorepo, then this solution won’t work.
Nice video, thank you. This is what I wanted ever since. In this architecture, is it possible to import one or more prisma models from one application to another application? For example: Application "Auth" with model "User" and Application "Blog" with model "Author", I import the User model into the Author model to provide a relationship.
In the channel I have a video of creating nest + react monorepo using turborepo, should allow you to share types. Also have a video on using ts-rest with nest, which creates a end-to-end type safety between your api and client. Check those out!
Haven’t tried NX yet but have heard good things. I have personally tried turborepo however which is another alternative, I have a video on using that to create a nest + react monorepo if you’re interested in seeing what that looks like
Warp terminal in beginning. I was using Monokai Pro theme here, I think that comes with its own icons? I don’t really remember changing the icons manually
Great video! I am looking for a solution that will separate my REST API code with Background Workers Logic (CRON + Bull). I thought that running these functionalities in different apps (and on different threads) can boost performance. Do you think that this a good usecase with concept showed in the video?) Thanks for opinion and useful videos!
Yes! If your cron jobs are expensive it would be a good idea run those in their own server (or even server-less) but the big selling point here with monorepos would be the ability to share code. So for example if your rest api runs the same queries as your cron and they are separate “apps” then that code sharing is much easier in a monorepo. Alternatively for Nestjs specifically I know they have the ability to have dynamic modules, so another option for example is one app deployed to multiple servers but only one specific server is designated as the “worker” for cron jobs if that makes sense, e.g. you can use an env variable to enable a dynamic module which contains your scheduler
I'd like to see an example of docketing microservices into a monorepo, but each separate microservice in a different container, isn't that far-fetched or is it?
You just want multiple docker containers made off of a monorepo? Yeah I don’t see why not, it’s possible but it will have its challenges since we have a bunch of code shared
Hi! How do you build your shared library. Can you publish this lib in a private repo and install it in your apps and make use of it this way? Can you keep the code of this shared library in the same monorepo?
Good questions. You can build the shared library just like the apps using “nest build library-name”, however once you import the library into an app technically it should already become packaged with that app’s dependencies when that app is built so you might not need the extra build step. The intention here is to have the library share code within the same monorepo, almost like you have your own private npm, so yes on your last question that is the point (as also shown in this video)
In the video I mentioned that you’d still need to individually use a command to start each app, so the logic or order of how that happens is ultimately up to you. Not sure what those conditions would look like for you but you definitely could write your own script to pull it off I imagine
This setup is specifically for Nest apps only, if you’re interested in adding other non-Nest project I recommend using turborepo or NX. I have a video on turborepo in the channel if you’re interested
@@mariusespejo Thanks, but the problem with turborepo approach is NestJS server doesn't automatically restart when imported code from shared typescript project has changed, if I restart it manually it works (latest changes applied) but that's cumbersome, in your video its just React and NestJS without a shared project and so it doesn't solve this problem
i would highly suggest to use nx, instead of the nest monorepos, as it offers a wide variety of different plugins (i.e., also allows to host react, angular, ... apps within the monorepository)
Yes this is a simple Nest-only setup, anything more complicated use nx or turborepo
Thank you so much for sharing the knowledge i would suggest if you could make a seperate vedio explaining nestjs microservices because thats something i want to learn and you are my go to option for nestjs tutorials 😂
Thanks for the suggestion! I do hope to create much more nest content this year!
Thank you for the content, Sir. Also, could you explain more about migrations in Nestjs monorepo? I'm using TypeOrm and I haven't figured out what is the best practice since when I build each app, Nestjs use webpack and bundles the codes into one file only.
Great video, Marius! Very insightful. 👏
I have a question, though… will those sub-apps share the same env created in the root?
That would depend on your deployment strategy
Very helpful, as always. I love the NestJS content. Building on this example, I'd like to see what a devcontainer would look like. To deploy to k8s, would you publish a separate image for each app? At what point would you think about adding nx?
There are some challenges with using docker on a monorepo, if you plan to do that honestly you would be better off just using turborepo or nx which likely would offer much better support for it.
For example here’s some docs from turborepo that talks about some of the challenges and how you’d solve it: turbo.build/repo/docs/handbook/deploying-with-docker
Not very familiar with nx yet, but in general I think any setup that’s slightly more complex than what I show here is probably worth switching over. Also if you think you’d mix other types of applications into your monorepo, then this solution won’t work.
Nice video, thank you. This is what I wanted ever since.
In this architecture, is it possible to import one or more prisma models from one application to another application?
For example: Application "Auth" with model "User" and Application "Blog" with model "Author", I import the User model into the Author model to provide a relationship.
You should be able to, turborepo supports having internal libraries specifically for code that is shared across applications.
Hey Marius, do you have an example of deploying a Nest microservices monorepo using serverless and AWS lambda?
Thank you for this, it was really helpful
Hi! How about share types in monorepo for frontend and nest?
Great videos, Thanks!
In the channel I have a video of creating nest + react monorepo using turborepo, should allow you to share types. Also have a video on using ts-rest with nest, which creates a end-to-end type safety between your api and client. Check those out!
Do you also use something like NX and what would it bring to to the table, thanks!
Haven’t tried NX yet but have heard good things. I have personally tried turborepo however which is another alternative, I have a video on using that to create a nest + react monorepo if you’re interested in seeing what that looks like
@@mariusespejo Thanks Marius.
What terminal is that? (Also what icon set are you using on VSCode? Looks new and slick!
I think the terminal is Wrap.
Warp terminal in beginning. I was using Monokai Pro theme here, I think that comes with its own icons? I don’t really remember changing the icons manually
Great video!! Thanks a lot!!!! Keep it up!
Thank you!
Great video! I am looking for a solution that will separate my REST API code with Background Workers Logic (CRON + Bull). I thought that running these functionalities in different apps (and on different threads) can boost performance. Do you think that this a good usecase with concept showed in the video?) Thanks for opinion and useful videos!
Yes! If your cron jobs are expensive it would be a good idea run those in their own server (or even server-less) but the big selling point here with monorepos would be the ability to share code. So for example if your rest api runs the same queries as your cron and they are separate “apps” then that code sharing is much easier in a monorepo.
Alternatively for Nestjs specifically I know they have the ability to have dynamic modules, so another option for example is one app deployed to multiple servers but only one specific server is designated as the “worker” for cron jobs if that makes sense, e.g. you can use an env variable to enable a dynamic module which contains your scheduler
I'd like to see an example of docketing microservices into a monorepo, but each separate microservice in a different container, isn't that far-fetched or is it?
You just want multiple docker containers made off of a monorepo? Yeah I don’t see why not, it’s possible but it will have its challenges since we have a bunch of code shared
Hi! How do you build your shared library. Can you publish this lib in a private repo and install it in your apps and make use of it this way? Can you keep the code of this shared library in the same monorepo?
Good questions. You can build the shared library just like the apps using “nest build library-name”, however once you import the library into an app technically it should already become packaged with that app’s dependencies when that app is built so you might not need the extra build step. The intention here is to have the library share code within the same monorepo, almost like you have your own private npm, so yes on your last question that is the point (as also shown in this video)
Let's say I want to create a CLI for my API. Would you use this method? or would you create another specific repository for the CLI?
Thank you sir
Thank you 🎉
What is the name of ur icon and theme in ur vscodeM
Thanks 🙌😊
is it possible in production we decide which app or more apps should be start first and in some condition triggers another app to start?
In the video I mentioned that you’d still need to individually use a command to start each app, so the logic or order of how that happens is ultimately up to you. Not sure what those conditions would look like for you but you definitely could write your own script to pull it off I imagine
Is it possible to include non-NestJS projects in this monorepo? For example, a react native project or ElectronJS project
This setup is specifically for Nest apps only, if you’re interested in adding other non-Nest project I recommend using turborepo or NX. I have a video on turborepo in the channel if you’re interested
@@mariusespejo Thanks, but the problem with turborepo approach is NestJS server doesn't automatically restart when imported code from shared typescript project has changed, if I restart it manually it works (latest changes applied) but that's cumbersome, in your video its just React and NestJS without a shared project and so it doesn't solve this problem
I see, in that case NX might be good to try although I have personally haven’t had a chance to so not sure if it solves your problem
Hı bro can you do a video about rabbitmq usage in nestjs ? I need it too much.i can not find a good video on youtube.
I love you.........
😍
In a real world scenario it is not so simple and easy.
Depends on the situation