Okay, so we're ready to get started creating our app.
We're going to be making heavy use of the net CLI in this course.
It's going to help us quickly and efficiently scaffold our microservices and allow us to add to our
application as we develop it over time very easily.
And it's super simple to install if you don't already have it.
Just make sure you run NPM install G for global the Nestjs CLI.
So if you get a permissions error when installing the CLI, just make sure you run this command in pseudo
mode and enter your password.
So after we have the CLI installed we are going to use it to generate a new project and we're going
to call this sleeper, this Airbnb clone, we're going to call it Sleeper with an R, feel free to call
it whatever you'd like and we'll go ahead and scaffold the application for this app.
I'm going to make use of NPM as my package manager because it is the quickest as it caches your node
modules and makes it a lot easier to run installation.
So after our project is fully initialized, we're going to CD into the sleeper directory and we can
simply run NPM run, start to make sure that our application back end server will start up and we can
see that our NEST application has successfully started.
Okay, so I've gone ahead and opened up the project in VS code, which is the code editor I will be
using.
And of course by default we have the bare bones of a nestjs application out of the box with our Main.ts
file, creating the nest application through the app module and then listening on HTTP port 3000 for
incoming requests and out of the box.
We have a single app dot controller, which is a get route that simply will call the app service and
return a Hello world string.
Okay, so I've also gone ahead and now opened up Postman, which we will use in this course to test
out HTTP requests against our Nestjs application.
You can use whichever HTTP client you'd like.
We're going to run an HTTP localhost 3000 get request at our server and we should get that.
Hello world response back because of that app dot controller so we can see that our app is fully up
and running and ready to go.
So back in our terminal I've exited out of the nest server and we are ready to get started on our application.
The first part of our application is going to be building out a common library that all of our different
microservices can use for common operations like database access, authentication, logging and more.
The benefit of this approach is that we only need to write this common code one time and then we can
import these modules that we're going to create into each different microservice and reuse that so that
we don't have to rewrite it over and over again.
For all of these common cross-cutting concerns.
Now the nest CLI makes this really easy for us, so we're going to convert our existing standalone project
into a mono repo where we'll have this common shared module alongside with each one of our microservice
apps that we're going to create.
It's very simple to get started.
We are just going to run, nest, generate library, and then we can give the name of the library.
So in this case, I'm going to call the library common because that's where all of our common code between
these different applications is going to live.
We can stick with the default app prefix and we can see that NEST has added this new Libs directory
with our common lib and then updated some different files here.
The nest CLI JSON, our package.json and the TS config.
So let's go back into VS code and take a look.
We can see this new libs directory here that has a ts config dot lib dot json that is extending our
root ts config.
So our root nestjs ts config is going to be shared amongst this common module library as well as all
of our different applications and we can see the paths here that our application can use to access our
common library.
Next, if we go into the nest CLI JSON, we can see we have a project section now where we actually
have our common library here specified with some metadata about it.
And lastly, if we go into the new common library, we can see we have a common module out of the box
with a common service and a root index.ts that is exporting these so that external applications can
import them and use them.
So in this lecture we have bootstrapped our application and converted it into a mono repo so that we
can easily share code.
We are now ready to start building out our common library so that we can reuse code amongst our microservices
and make developing our backend very easy.
Let's jump right in and I'll see you in the next one.