WEBVTT

1
00:00.950 --> 00:02.720
Hi everyone.

2
00:04.220 --> 00:06.860
In this video let's discuss about.

3
00:06.890 --> 00:14.120
Nest CLI, command line interface okay.

4
00:15.080 --> 00:22.490
In the nestjs documentation inside the CLI command line interface right here click on overview.

5
00:23.600 --> 00:29.360
Actually in the beginning of this course we already installed the nestjs.

6
00:29.360 --> 00:30.860
CLI right here.

7
00:30.860 --> 00:38.390
If you click on the introduction right here we can we already installed that right.

8
00:38.540 --> 00:41.600
And thank to install the NestJS

9
00:42.050 --> 00:46.640
CLI, we can create with the "nest"

10
00:49.100 --> 00:52.580
And new project name right here okay.

11
00:53.810 --> 00:58.700
The CLI is just a tool to make the developer life easier

12
00:59.270 --> 00:59.900
to work

13
01:01.220 --> 01:01.670
Okay.

14
01:01.700 --> 01:06.920
Now firstly let me click on the usage right here.

15
01:06.920 --> 01:10.490
You can read more about something right here if you want.

16
01:12.110 --> 01:24.140
If I click on the usage, it have some command line, for "nest new" or "nest n" for shorthand to create

17
01:24.290 --> 01:25.610
the project.

18
01:26.450 --> 01:36.200
Okay, we already see it in the beginning of the course, and if I scroll down a little bit, it has a

19
01:36.200 --> 01:38.000
something called "nest generate"

20
01:39.080 --> 01:41.990
It will generate with some semantics.

21
01:42.380 --> 01:42.740
Okay.

22
01:42.740 --> 01:46.850
We can use generate or shorthand like "g".

23
01:49.220 --> 01:49.550
Okay.

24
01:49.580 --> 01:51.500
With the same schematic and name.

25
01:52.070 --> 01:53.900
Now let's see what is schematic.

26
01:55.790 --> 01:58.100
If you scroll down into the schematics.

27
01:58.250 --> 02:04.790
Right here, we can see it can generate something like "app library class controller".

28
02:05.600 --> 02:06.170
Right.

29
02:07.400 --> 02:09.170
Middleware module.

30
02:11.780 --> 02:12.620
Or service.

31
02:12.860 --> 02:15.530
Now let me show you how we can do that.

32
02:16.490 --> 02:21.110
Firstly I think I will remove everything right here.

33
02:21.470 --> 02:21.920
Okay.

34
02:21.950 --> 02:26.810
Remove everything and go back with default one.

35
02:28.310 --> 02:39.560
For example, if I want to create the folder and we have a post controller, post module and post service

36
02:40.640 --> 02:49.310
we'll not do that by hand like the first section, because right now we already have a.

37
02:51.980 --> 02:53.960
Nest CLI

38
02:55.490 --> 02:58.910
Firstly, let me remove the module right here.

39
03:00.290 --> 03:01.730
I think that will clean up.

40
03:13.430 --> 03:13.730
A bit.

41
03:15.680 --> 03:16.430
Module.

42
03:20.360 --> 03:20.930
Okay.

43
03:22.730 --> 03:27.260
And now firstly, I will use the net.

44
03:28.160 --> 03:29.540
"nest g"

45
03:33.320 --> 03:36.800
nest generate and schematic

46
03:36.830 --> 03:40.520
I will firstly I will create a module first.

47
03:41.060 --> 03:41.420
Okay.

48
03:41.450 --> 03:44.690
Because the module is very important in NestJS.

49
03:44.720 --> 03:48.140
I will call the "post".

50
03:50.990 --> 03:52.190
For example like this.

51
03:52.400 --> 03:55.310
Now you can see, what happened right now.

52
04:07.970 --> 04:18.980
Well, if it's not working in your case, you can try, you can add the prefix.

53
04:19.370 --> 04:21.740
"npx" right now.

54
04:21.950 --> 04:22.310
Okay.

55
04:22.340 --> 04:25.910
And this next generate module and post.

56
04:27.980 --> 04:29.360
Let me enter.

57
04:35.510 --> 04:37.010
And let wait a bit.

58
04:45.710 --> 04:48.410
Now you can see, it already create.

59
04:48.950 --> 04:53.470
At the same time and will update the app module.

60
04:53.800 --> 04:58.990
Now let me see what actually inside the app module.

61
04:59.530 --> 05:02.410
But let's look at the post, in the post.

62
05:02.470 --> 05:07.390
We already have something called "PostModule" like this.

63
05:08.440 --> 05:09.010
Very cool

64
05:09.040 --> 05:09.550
Right?

65
05:11.260 --> 05:22.630
And inside the app module it will auto import the "PostModule" inside the import statement.

66
05:22.960 --> 05:28.480
Okay, so that's it.

67
05:36.370 --> 05:43.000
Now let me create something like controller.

68
05:43.930 --> 05:47.260
Firstly, I think I will create a service first.

69
05:52.120 --> 05:52.600
Okay.

70
05:52.600 --> 05:53.170
It will.

71
05:53.170 --> 05:54.670
Auto provider.

72
05:55.000 --> 05:55.330
Okay.

73
05:55.330 --> 05:56.830
It will auto injection.

74
05:56.830 --> 06:03.910
You can see, if I clicked on the "PostService" right here, it will auto mark the "@Injectable"

75
06:04.060 --> 06:10.270
To the IOC container manage the "PostService" right.

76
06:10.630 --> 06:11.620
And it also.

77
06:13.720 --> 06:15.490
Add inside the providers.

78
06:16.120 --> 06:19.330
We already discussed in the first section.

79
06:20.260 --> 06:22.990
And now I will create a controller.

80
06:29.680 --> 06:30.160
Okay.

81
06:30.190 --> 06:34.360
We also have a controller like this right.

82
06:34.390 --> 06:35.020
Very cool.

83
06:36.400 --> 06:39.430
And the controller here is auto mark with the "post"

84
06:39.880 --> 06:46.630
Now I will discuss what is the "post" inside the controller right here in later.

85
06:47.290 --> 06:52.810
Don't worry about that, but let me remove the "spect"file for unit test.

86
06:55.900 --> 06:56.440
Okay.

87
06:58.090 --> 07:02.260
That is that for the command line user interface

88
07:03.700 --> 07:13.300
And when you work with the NestJS, we should use the command line interface, in the options

89
07:13.300 --> 07:15.370
we have a something option.

90
07:17.140 --> 07:25.330
If I scroll down to the option right here, we can see, if we don't want it auto generate the unit test.

91
07:25.360 --> 07:29.020
You can use the flag right here.

92
07:31.180 --> 07:33.730
I will show you how we can do that later.

93
07:34.690 --> 07:35.020
Okay.

94
07:35.050 --> 07:40.780
So that's it, we can read more about the different topics over here.

95
07:41.290 --> 07:44.290
But for now this is enough for the project.

96
07:44.380 --> 07:46.390
I will see you in the next one.