Express Server

Written by sanju

Updated on:

In this video.

WhatsApp Group Join Now
Telegram Group Join Now
Instagram Group Join Now

Let’s go ahead and start to create our expert server.

Because of that, we need to install the express package.

So inside our terminal, let’s go ahead and then install the package by using NPM.

I express and for this, make sure that you install the exact version as I’m going to install.

And that way after some days or months or years, if there are some big changes in the express package,

your code and mine will be the same.

So let’s go ahead and install the version.

4.1, 8.1.

Let’s hit enter and now let’s wait for express to finish installing and attach finished installing.

So let’s go ahead and then start to create our server.

So this is a file.

So here let’s go ahead and then require the express package as we installed X first.

And then after that let’s go ahead and create instance of express as app equal to express.

And here is going to be our metaverse.

And after that we are going to have our root and after root we are going to have our error handlers

middleware down here as that.

And then lastly, we are going to listen to our server, listen to server.

So let’s pull up this comment step by step.

Let’s start with the let’s say to the server.

So first let’s create a port that we are going to use going to be process dot E and V dot port.

And if there is no value on the port, then we are going to use our custom port as 9000.

We can use any port of your choice, but make sure that this port is going to be used by different application.

So lastly, let’s go ahead and then listen to our server by using the port and comma our callback function.

I’m going to use console that plug because console plug is also a function.

So here I will say that server is up and running on ports.

Let’s inject the dynamic value as that.

So let’s go ahead and then configure our package to JSON file.

So here we are going to use Main at server JS and for the script you are going to use start.

And for this we’re going to use Node to start our server, going to be as Node and then the name of

the file which is server dot G’s.

So next step is let’s go ahead and then run our server by making use of NPM, run, start and there

we go.

Server is running on port 9000.

Perfect.

But I forgot one more for the core root.

So here is our root folder.

Now our folders are complete.

All right, the next video, let’s go ahead and then start to create some dummy route.

And after that, we are going to refactor its use MVC design pattern and from there we integrate MongoDB

into it.

All right, so let’s get working, guys.

Related Post

Leave a Comment