How I manage multiple NestJS applications

Поділитися
Вставка
  • Опубліковано 5 жов 2024
  • In this video we walk through how to create and maintain multiple Nest applications in a single repository using Nest CLI's built-in support for monorepo. Plus we'll walk through how to create libraries to share code across your applications.

КОМЕНТАРІ • 47

  • @z0rn86
    @z0rn86 9 місяців тому +13

    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)

    • @mariusespejo
      @mariusespejo  9 місяців тому

      Yes this is a simple Nest-only setup, anything more complicated use nx or turborepo

  • @pathanazamkhan6746
    @pathanazamkhan6746 9 місяців тому

    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 😂

    • @mariusespejo
      @mariusespejo  9 місяців тому

      Thanks for the suggestion! I do hope to create much more nest content this year!

  • @eyoelijah9332
    @eyoelijah9332 2 місяці тому

    Thank you for this, it was really helpful

  • @joebowbeer
    @joebowbeer 9 місяців тому +1

    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?

    • @mariusespejo
      @mariusespejo  9 місяців тому

      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.

  • @robtangled8816
    @robtangled8816 8 місяців тому

    Great video!! Thanks a lot!!!! Keep it up!

  • @thang1324
    @thang1324 5 місяців тому

    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.

  • @joshdev4404
    @joshdev4404 8 місяців тому

    Great video, Marius! Very insightful. 👏
    I have a question, though… will those sub-apps share the same env created in the root?

    • @mariusespejo
      @mariusespejo  8 місяців тому +1

      That would depend on your deployment strategy

  • @carlosmoliveira
    @carlosmoliveira Місяць тому

    Hey Marius, do you have an example of deploying a Nest microservices monorepo using serverless and AWS lambda?

  • @dungng1321
    @dungng1321 9 місяців тому

    Thank you 🎉

  • @nikitabalakin1498
    @nikitabalakin1498 9 місяців тому

    Thank you sir

  • @samislam2746
    @samislam2746 Місяць тому

    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?

  • @fredhermannramandaniarivo7464
    @fredhermannramandaniarivo7464 5 місяців тому

    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.

    • @mariusespejo
      @mariusespejo  5 місяців тому

      You should be able to, turborepo supports having internal libraries specifically for code that is shared across applications.

  • @lardosian
    @lardosian 9 місяців тому +1

    Do you also use something like NX and what would it bring to to the table, thanks!

    • @mariusespejo
      @mariusespejo  9 місяців тому +1

      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

    • @lardosian
      @lardosian 9 місяців тому

      @@mariusespejo Thanks Marius.

  • @mochamadrasyad338
    @mochamadrasyad338 9 місяців тому

    Thanks 🙌😊

  • @luissarabia8436
    @luissarabia8436 9 місяців тому

    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?

    • @mariusespejo
      @mariusespejo  9 місяців тому

      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

  • @andrejs0tube
    @andrejs0tube 9 місяців тому

    Hi! How about share types in monorepo for frontend and nest?
    Great videos, Thanks!

    • @mariusespejo
      @mariusespejo  9 місяців тому

      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!

  • @gadgetboyplaysmc
    @gadgetboyplaysmc 9 місяців тому

    What terminal is that? (Also what icon set are you using on VSCode? Looks new and slick!

    • @kareemmahlees3597
      @kareemmahlees3597 9 місяців тому

      I think the terminal is Wrap.

    • @mariusespejo
      @mariusespejo  9 місяців тому +1

      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

  • @illia_mikhow
    @illia_mikhow 8 місяців тому

    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!

    • @mariusespejo
      @mariusespejo  8 місяців тому

      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

  • @mehdiwow5388
    @mehdiwow5388 4 місяці тому

    What is the name of ur icon and theme in ur vscodeM

  • @ViciuSRO
    @ViciuSRO 9 місяців тому

    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?

    • @mariusespejo
      @mariusespejo  9 місяців тому +1

      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)

  • @Justdoit-oo2bp
    @Justdoit-oo2bp 6 місяців тому

    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.

  • @SatryaNouvanda
    @SatryaNouvanda 9 місяців тому

    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?

    • @mariusespejo
      @mariusespejo  9 місяців тому

      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

  • @VeeWebCode
    @VeeWebCode 8 місяців тому

    I love you.........

  • @veracsthedefiled
    @veracsthedefiled 9 місяців тому

    Is it possible to include non-NestJS projects in this monorepo? For example, a react native project or ElectronJS project

    • @mariusespejo
      @mariusespejo  9 місяців тому

      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

    • @veracsthedefiled
      @veracsthedefiled 9 місяців тому

      @@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

    • @mariusespejo
      @mariusespejo  9 місяців тому +1

      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

  • @tamasmolnar4157
    @tamasmolnar4157 4 місяці тому

    In a real world scenario it is not so simple and easy.