Migrating backend app to NX

How to migrate simple existing applications to NX

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

This lesson preview is part of the Next-Level Angular Apps with NX course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to Next-Level Angular Apps with NX, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Next-Level Angular Apps with NX
  • [00:00 - 00:11] In this lesson, we're going to migrate the backend application that I presented to you in previous lesson to empty NX-Monarepo. So let's start by creating an empty NX-Monarepo.

    [00:12 - 00:23] All options that I decided to choose are visible on the screen. Everything has been installed, so now let's add necessary dependencies for NX-N EST.

    [00:24 - 00:33] So yarn add -d NX-NEST. And again, we need to wait a few seconds for installation process end.

    [00:34 - 00:54] The last thing we need to do to have that empty NX-Monarepo. And this may take a while.

    [00:55 - 01:05] Generation process has ended, so let's check what is inside our application. So we have apps, backend, and we have our NEST.js application here.

    [01:06 - 01:18] And as you can see, the folder structure looks similar to standard NEST.js application. NX tries to stick as much as it is possible to the official folder structure, for example, in NEST.

    [01:19 - 01:26] So the migration process is very easy. All I need to do is to delete all these files that I have here inside of the app.

    [01:27 - 01:30] And then replace it with my own files. So let's do this.

    [01:31 - 01:40] I will simply open a C directory in my backend here. I will copy all the files from here, and I will paste it in the app.

    [01:41 - 01:45] As you can see, everything is copied. We have two main files, so we should deal with that.

    [01:46 - 01:52] So let's delete the copied one. And let's check what is in the original one.

    [01:53 - 01:56] It's very similar. And even the import path should work.

    [01:57 - 02:02] So let's try to start it. To start the backend application in our NX-Monarepo, I need to execute comment.

    [02:03 - 02:09] Yarn, NX, serve, and the name of the application. So my app is named backend, so backend.

    [02:10 - 02:25] And as you can see, everything started, and we have the same endpoints here. So we have our hello, we have our rooms, we've get and post, and we have our meetings with get and post.

    [02:26 - 02:30] So with that simple steps, we have migrated the whole backend application to NX -Monarepo.