WEBVTT

1
00:00.530 --> 00:01.970
Hi everyone.

2
00:01.970 --> 00:06.140
Right now we already have a post and user.

3
00:06.470 --> 00:06.890
Okay.

4
00:06.920 --> 00:09.290
And let me show you how we can.

5
00:11.540 --> 00:15.380
Create a swagger UI for this project.

6
00:15.410 --> 00:20.960
Okay, so what is swagger. Swagger is just similar with the postman.

7
00:21.410 --> 00:31.130
Okay but it's the website version and if you want to do that, you can feel free to do that with NestJS.

8
00:32.870 --> 00:33.320
Okay.

9
00:33.440 --> 00:37.880
Now let's click on the open api and click on the introduction.

10
00:37.910 --> 00:41.690
And firstly, make sure we install this package okay.

11
00:42.710 --> 00:46.190
This is the package. I'll open here.

12
00:46.670 --> 00:48.230
And I will install the package.

13
00:50.720 --> 00:59.120
And while it's being install I will show you, inside the bootstrap application main.ts.

14
00:59.330 --> 01:02.480
We will use something like this code okay.

15
01:03.260 --> 01:06.500
And to be honest I don't know what does it mean?

16
01:07.640 --> 01:08.030
Okay.

17
01:08.060 --> 01:17.420
So the first one is just needs to copy & paste and see what is that.

18
01:18.110 --> 01:20.960
And after that we will modify later.

19
01:20.990 --> 01:21.590
Okay.

20
01:21.770 --> 01:24.260
Don't try to understand everything right now.

21
01:25.370 --> 01:32.570
Let me import the document builder and also swagger module.

22
01:33.170 --> 01:33.560
Okay.

23
01:34.220 --> 01:39.260
That is and let me show you how it can be used.

24
01:41.000 --> 01:48.650
If I scroll down if I run the project it will create something called localhost:3000/api.

25
01:48.950 --> 01:49.550
Okay.

26
01:49.790 --> 01:52.940
We will we can access into the URL right here.

27
01:57.170 --> 02:01.220
If I access, now we have something called swagger UI right.

28
02:02.660 --> 02:15.050
And this you can see, this is similar with the postman right? Now

29
02:15.230 --> 02:17.690
Let me rename it a little bit right here.

30
02:17.690 --> 02:23.510
For example like "Cats example" I will rename to NestJS

31
02:25.880 --> 02:28.790
Tutorial okay.

32
02:29.300 --> 02:33.440
And here we will NestJS description.

33
02:35.390 --> 02:40.880
let me refresh right now okay.

34
02:40.880 --> 02:46.970
We already changed and "cats" right here is the the "tag"

35
02:47.570 --> 02:50.780
And I will show you what is the "tag" later.

36
02:51.770 --> 02:53.420
Don't worry about them. Firstly

37
02:53.450 --> 02:55.100
Let me remove the addTag right here

38
03:00.800 --> 03:01.940
And one more thing.

39
03:01.940 --> 03:06.740
How we can change the URL for example I don't want it use the /api

40
03:07.460 --> 03:09.380
And I want you to swagger.

41
03:09.380 --> 03:09.950
For example.

42
03:09.950 --> 03:14.870
Like that. In order to do that, we can change right here inside the setup.

43
03:15.380 --> 03:21.350
We can change the URL to swagger like that, and let refresh

44
03:22.670 --> 03:27.500
And now if I refresh right here, now this also works, right?

45
03:28.010 --> 03:37.220
And now because we have an app module right here, and we have an app controller with the get method.

46
03:37.220 --> 03:41.870
So it will create it will group the endpoint for me

47
03:42.920 --> 03:43.430
Okay.

48
03:44.510 --> 03:45.680
And one more thing.

49
03:45.680 --> 03:50.270
For example I will create one more controller inside the user.

50
03:50.540 --> 03:51.020
Okay.

51
03:51.140 --> 03:53.510
Let me open the post right here.

52
03:54.620 --> 03:54.890
And.

53
03:58.280 --> 04:06.890
Now let me copy everything inside the post controller and paste inside the user controller.

54
04:06.950 --> 04:07.520
Okay.

55
04:07.580 --> 04:09.830
Now I will rename a little bit.

56
04:12.140 --> 04:12.830
I will name to.

57
04:12.860 --> 04:17.510
Here will be the users and here will be the user controller

58
04:22.400 --> 04:22.850
Okay.

59
04:22.850 --> 04:23.930
We can

60
04:26.000 --> 04:27.020
I think we don't need

61
04:27.050 --> 04:27.920
all of that

62
04:29.840 --> 04:32.360
Okay, let me remove something.

63
04:33.650 --> 04:33.980
Okay.

64
04:34.010 --> 04:37.610
I just need to use the @Post and @Get

65
04:39.110 --> 04:41.900
And let me remove thing right now.

66
04:44.030 --> 04:47.210
We can use the CreatePostDTO if you want.

67
04:47.960 --> 04:50.120
And right here, we don't need the post server

68
04:51.200 --> 04:54.500
And right here, post.

69
04:59.750 --> 05:01.460
Here will be get.

70
05:01.790 --> 05:04.250
Okay, I will do that simple like this.

71
05:04.760 --> 05:07.790
And now let's see what happens right now. If

72
05:07.790 --> 05:08.540
I refresh.

73
05:09.560 --> 05:13.910
Now it will create one more group of a user for me, right?

74
05:14.690 --> 05:15.530
Very cool.

75
05:17.960 --> 05:18.680
And.

76
05:21.080 --> 05:26.120
I think that's enough for the video, so I will see you in the next one.