WEBVTT

00:03.760 --> 00:05.320
Hey, did everyone share?

00:05.320 --> 00:09.770
And in this video we will be creating our first application, which is the auth system.

00:09.790 --> 00:11.440
Now, let me remind you one more time.

00:11.440 --> 00:15.220
We have already studied not just about Mongoose, but also about the Dot, D and V.

00:15.220 --> 00:18.280
So all that we have studied is now going to go into this project.

00:18.280 --> 00:19.750
Then that's how we'll be doing.

00:19.930 --> 00:24.970
Another big reminder that we are not going to separate the entirety of the project into all multiple

00:24.970 --> 00:25.300
files.

00:25.300 --> 00:26.560
That's what I love to do.

00:26.560 --> 00:31.420
But if I'll do it right now, it might create confusion some of the for some of the absolute beginners.

00:31.420 --> 00:32.830
So we won't be doing that.

00:32.830 --> 00:37.300
We will be rather separating it one by one, step by step, a little bit in this section, a little

00:37.300 --> 00:38.680
bit in the next own section.

00:38.680 --> 00:39.580
And just like that.

00:39.580 --> 00:43.810
But don't worry, I'll tell you how the scalability is maintained and how other developers can come

00:43.810 --> 00:47.410
in and still can have an overview of how the project is structured out.

00:47.590 --> 00:51.820
So for this, let's go up here so I can actually go ahead and bring this up.

00:51.940 --> 00:53.110
We can actually minimize this.

00:53.110 --> 00:54.370
We don't need it right now.

00:54.460 --> 01:00.220
Let's go ahead and clean this up and I have already some stuff, so I'll go one directory back and do

01:00.250 --> 01:00.760
LRS.

01:00.910 --> 01:05.290
So these are a couple of my projects that we have built up in the last section.

01:05.290 --> 01:12.040
Now let's go ahead and create a new directory and we will be calling this up as ae auth system.

01:13.030 --> 01:14.020
That's nice.

01:14.050 --> 01:14.560
Okay.

01:14.800 --> 01:20.650
Now once I go into this AE auth system, I need to create a a package here.

01:20.650 --> 01:21.970
The packages are JSON file.

01:21.970 --> 01:24.100
So I'm going to go ahead and say NPM in it.

01:24.100 --> 01:27.250
We are not interested right now in answering all the questions.

01:27.250 --> 01:30.070
So we'll just say dash y to accept all the default.

01:30.070 --> 01:34.000
Yes, there is a way to change the default as well, but that's a little bit out of the scope.

01:34.000 --> 01:37.450
Probably a crash course somewhere on the YouTube later on.

01:37.570 --> 01:41.170
Okay, once this is done, then I obviously want to install some of the libraries.

01:41.170 --> 01:47.680
Express is definitely going to be one of them, but I will skip now from from now onwards, I'll skip

01:47.680 --> 01:50.560
the swagger part because I think you can do it now.

01:50.560 --> 01:54.880
We have done quite an extensive detail on writing the documentation, so I won't be adding the swagger.

01:54.880 --> 02:00.520
Now, we also have studied a little bit about the dot envy, so that is what we need to now inject.

02:00.520 --> 02:05.170
And apart from that we also going to have a mongoose which is again ODM.

02:05.170 --> 02:08.650
We have studied a little bit now we want to study more in depth about it.

02:08.650 --> 02:11.470
So these are the basic ones that we need to install now.

02:11.620 --> 02:15.010
Okay, this is that's quite fast this time.

02:15.010 --> 02:17.560
So we're going to go ahead and open up our code editor here.

02:17.560 --> 02:19.930
And this shouldn't take too much of the time here.

02:19.930 --> 02:21.070
So I trust this.

02:21.370 --> 02:22.360
And there we go.

02:23.870 --> 02:24.230
Okay.

02:24.350 --> 02:26.630
So this is all what we got up here.

02:27.550 --> 02:28.660
And there we go.

02:28.690 --> 02:31.920
Now in here, we're going to have a package of JSON file.

02:31.930 --> 02:34.660
Let's go ahead and create a start script.

02:34.840 --> 02:40.450
Now, in the START script, we are going to go ahead and say Node, which will be firing up indexed

02:40.450 --> 02:42.670
or us, because obviously we want to push it up.

02:42.850 --> 02:48.610
Now, this is all great, but I don't want to keep on reloading my server, so I want to install the

02:49.060 --> 02:50.140
Node one as well.

02:50.140 --> 02:56.890
So I'm going to go ahead and say NPM install, but with the Dash dx of Node one, let's go ahead and

02:56.890 --> 02:58.270
install that also.

02:59.080 --> 03:01.270
So it's going to take a little bit time.

03:01.270 --> 03:03.790
And again, I think I should use the in-built terminal now.

03:03.820 --> 03:09.100
Now what we can do is we can actually go ahead and put up a comma and duplicate this line and can simply

03:09.100 --> 03:12.040
go ahead and say that I want to have an NPM.

03:12.340 --> 03:17.230
Instead of saying NPM start, we are going to have an NPM run dev as a command.

03:17.230 --> 03:20.980
And in this one, this is going to be governed by Node one.

03:22.090 --> 03:22.850
There we go.

03:22.870 --> 03:24.910
Node one will run indexed args file.

03:24.910 --> 03:27.010
Make sure to remove the trailing comma here.

03:27.010 --> 03:28.210
This is all great.

03:28.240 --> 03:33.370
Now what this is happening or what we are doing is whenever you deploy an anything on the server, it

03:33.370 --> 03:36.370
just runs the one command always which is NPM start.

03:36.370 --> 03:39.550
So a dependency this time is not going to bother this again.

03:39.550 --> 03:43.720
There are so many strategies that we can work on with that, but you get the idea what we are doing.

03:44.050 --> 03:47.480
Okay, once we are done with that, now we need to create a couple of folders and file.

03:47.500 --> 03:50.380
Now specifically, I'm going to go ahead and create an index.

03:50.620 --> 03:53.770
JS But also I will be creating an app.

03:54.010 --> 03:57.160
JS And I'll tell you the reason why we are going to do it in a minute.

03:57.280 --> 04:03.160
Okay, so this is all good, this is all great, but we need to create a couple of more folders where

04:03.160 --> 04:04.180
all the things are going.

04:04.180 --> 04:09.670
Now, remember, we need to connect with database also we need to put up our env file.

04:09.670 --> 04:13.690
Also we will be creating our models also and there can be more folders.

04:13.690 --> 04:16.450
But this is the bare minimum basics that we need to go now.

04:17.260 --> 04:23.590
Okay, so for this, what I really prefer is actually do it through the terminal because if I do it

04:23.590 --> 04:28.840
from here, it sometimes put folders all inside and I don't really like that one.

04:28.840 --> 04:31.720
So we're going to go ahead and use my terminal again.

04:31.720 --> 04:34.570
If you don't know the terminal commands or anything, don't sweat it out.

04:34.570 --> 04:35.230
It's all okay.

04:35.230 --> 04:38.350
You can just use the system, but make sure your structure looks like this.

04:38.350 --> 04:40.300
I'll show you in the finder as well.

04:40.300 --> 04:41.890
So this is all what we have now.

04:41.890 --> 04:44.080
I'm going to go ahead and create a couple of directories.

04:44.080 --> 04:48.880
So the first directory that we are going to have is all the models, or you can just call it as model

04:48.880 --> 04:49.840
however you like.

04:49.840 --> 04:52.240
There is no wrong or there is no right in this one.

04:52.420 --> 04:58.780
Apart from this we have the model and then we are going to have some of the config now putting up the

04:58.780 --> 04:59.530
dot in the file.

04:59.530 --> 05:01.480
In the config or not, that's your call.

05:01.480 --> 05:02.410
I wouldn't be putting it.

05:02.410 --> 05:03.430
I wouldn't be putting it.

05:03.430 --> 05:05.410
I would be putting it into the project route.

05:05.410 --> 05:10.120
But still, there are some files that need to go and later on we are going to write some middleware

05:10.120 --> 05:11.710
and we're going to talk about them as well.

05:11.710 --> 05:15.040
So let's go ahead and create that directory as well once you do this.

05:15.040 --> 05:17.650
Now these directories are here under the project route.

05:17.680 --> 05:20.620
Now apart from this, we need to create a couple of files as well.

05:20.620 --> 05:26.020
So in the model, we are going to create a file which is going to be simple user dot JS.

05:26.050 --> 05:29.140
Now you want to keep it as all lowercase, all uppercase.

05:29.140 --> 05:29.920
It's up to you.

05:29.920 --> 05:32.170
Let's go ahead and use the lowercase again.

05:32.170 --> 05:33.550
A Totally your decision.

05:33.550 --> 05:35.590
It's not going to bother anything at all.

05:35.950 --> 05:37.270
So this is the basic.

05:37.270 --> 05:40.420
Now touch is a command which creates an empty file for me.

05:40.480 --> 05:47.710
Again, you might be having different one and I will be creating another file into into the config that

05:47.710 --> 05:50.080
will say database JS.

05:50.110 --> 05:55.900
This will be responsible for connecting with the database and then we are going to have a middleware.

05:55.900 --> 05:57.100
So we're going to have a middleware.

05:57.100 --> 05:59.410
We are going to call this one as all dot JS.

05:59.500 --> 06:01.600
Now why we are creating so many of the files.

06:01.600 --> 06:06.670
Yes, there will be usage of all of this, but actually creating all these files because I know what

06:06.670 --> 06:08.920
strategy I'm following up is actually a good structure.

06:08.920 --> 06:10.960
So in the config, I have database Node.js.

06:10.960 --> 06:15.280
In the middleware we have ordered JS, there is nothing in these files and in the model we are having

06:15.280 --> 06:20.310
user OC Going back, we will be touching just the app dogs.

06:20.350 --> 06:24.820
As of now we have installed everything that we kind of need for now, so let's go ahead and work on

06:24.820 --> 06:25.360
with that.

06:25.750 --> 06:29.470
So remember the first thing that we are going to do is create an express.

06:29.470 --> 06:35.380
So we're going to call X Press that is going to be coming up from require.

06:35.770 --> 06:38.260
And let's go ahead and say express.

06:38.980 --> 06:45.280
Now after that, we go ahead and create an app which is created by Express just like that.

06:45.280 --> 06:46.210
And there we go.

06:46.210 --> 06:51.280
Now it can have multiple routes, so we're going to go ahead and have a simple basic route, not length

06:51.940 --> 06:59.230
app dot get just like that and we'll have a home route and this home route will be having a comma and

06:59.230 --> 07:03.640
just like that request and response and there we go.

07:04.330 --> 07:10.420
And we're going to simply say that resource send and in here we are going to go ahead and simply say

07:10.420 --> 07:15.130
in the edge one that hello from earth.

07:17.030 --> 07:20.060
AWD system dash ae.

07:20.090 --> 07:20.690
There we go.

07:20.690 --> 07:25.670
And again, make sure you don't forget that this entire X1 needs to go in the double code that is absolute

07:25.670 --> 07:26.330
required.

07:26.390 --> 07:31.640
But one thing extra that we'll be doing in this file is instead of saying, listen here, we're going

07:31.640 --> 07:39.290
to go ahead and simply say that module DOT exports and we're going to go ahead and say AB while we are

07:39.290 --> 07:40.030
doing this.

07:40.040 --> 07:42.050
We could have just said, listen directly here.

07:42.050 --> 07:43.160
Yes, we could have.

07:43.160 --> 07:48.590
But eventually you're going to notice that sometimes this file gets so much of big with the middle layers

07:48.590 --> 07:52.820
and the roots and a whole bunch of other thing that it is better to keep your listening operation and

07:52.820 --> 07:54.170
all of that into a separate file.

07:54.170 --> 07:57.830
This is a good recommendation, so go ahead and just export this one.

07:57.950 --> 08:03.620
Remember in the package dot JSON, we saw that our node mom and the node are running the index file.

08:03.620 --> 08:08.750
So we are exporting this from the dogs and here we can go ahead and simply say, hey, I want to go

08:08.750 --> 08:13.820
ahead and import the app again, just like we were exporting using the require statement, we can do

08:13.820 --> 08:19.280
same, but this time instead of requiring from an installed library, we can go ahead and say from the

08:19.280 --> 08:21.170
current directory, just get me an app.

08:21.170 --> 08:27.650
Once this is being done, I can now go ahead and say listen and in here we're going to go ahead and

08:27.650 --> 08:30.170
say, hey, let's just listen on the port, 4000.

08:30.170 --> 08:32.720
Yes, we will be taking care of port in a minute.

08:32.750 --> 08:33.770
Not right now.

08:33.860 --> 08:40.130
We're going to go ahead and simply say, hey, let's run this one like this and say console, dot,

08:40.130 --> 08:40.940
log.

08:41.510 --> 08:50.990
And we will be saying server is running at port 4000 with of course Dippin Dots.

08:51.230 --> 08:52.490
Okay, so this is all done.

08:52.490 --> 08:53.570
This is all good.

08:53.570 --> 08:57.380
Let's go ahead and see if we are able to set up this match so far.

08:57.380 --> 09:03.560
So we're going to go ahead and say npm run dev because we want to keep it running up using the Node

09:03.560 --> 09:04.020
one.

09:04.160 --> 09:09.290
So we see that some of the crashes so it says app dot get is having some the issue.

09:09.290 --> 09:15.200
Let me go ahead and quickly see that why app get is having some issues there we go.

09:15.620 --> 09:19.520
Should be all happy now and server is running on the port.

09:19.580 --> 09:20.990
Come on, don't go anywhere.

09:21.170 --> 09:23.120
Let me bring up my.

09:24.270 --> 09:24.870
Screen.

09:24.870 --> 09:25.710
And there we go.

09:25.740 --> 09:27.840
Let's go ahead and try localhost 4000.

09:27.840 --> 09:28.830
Hello from our system.

09:28.830 --> 09:32.190
Okay, so so far this is looking absolutely fantastic.

09:32.190 --> 09:37.950
We have broke broke up the entire file into not too much, but at least some of that in the next video.

09:37.950 --> 09:39.270
We're going to continue from here.

09:39.270 --> 09:41.280
And let's catch up in the next video.
