1
00:00:00,790 --> 00:00:01,930
In this video.

2
00:00:01,930 --> 00:00:07,530
Let's get started by creating the root and controllers for our application.

3
00:00:07,540 --> 00:00:11,510
First step is that we are going to work with the users.

4
00:00:11,590 --> 00:00:19,120
After that, we will go ahead and work with the post API and then the comments API by the design pattern

5
00:00:19,120 --> 00:00:23,280
that we are going to use is called MVC design pattern.

6
00:00:23,290 --> 00:00:27,010
But before we get into that, I would like guys to move slowly.

7
00:00:27,010 --> 00:00:27,670
In that way.

8
00:00:27,670 --> 00:00:32,220
You better understand how the MVC design pattern works.

9
00:00:32,229 --> 00:00:40,090
So first step is we are going to write all the code on one file, then you go ahead and refactor using

10
00:00:40,090 --> 00:00:45,070
express routing and lastly to use MVC design pattern.

11
00:00:45,190 --> 00:00:53,620
So for the root, we're going to have this root first one going to be the user's root and next step

12
00:00:53,620 --> 00:01:00,790
going to be the post root and it's going to be the common root.

13
00:01:01,420 --> 00:01:01,930
All right.

14
00:01:01,930 --> 00:01:08,560
So let me remove this one and let me add beautiful command to the user's root.

15
00:01:10,520 --> 00:01:13,460
Likewise the post route.

16
00:01:15,110 --> 00:01:18,350
We are going to fill them up as we move on.

17
00:01:18,650 --> 00:01:21,680
And he is going to be the comments.

18
00:01:25,990 --> 00:01:26,410
All right.

19
00:01:26,410 --> 00:01:28,480
So let's start with the users.

20
00:01:29,080 --> 00:01:38,980
The first one is going to be post request going to be API for slash version one for slash users and

21
00:01:38,980 --> 00:01:44,110
for its last register going to be the register endpoint.

22
00:01:44,110 --> 00:01:55,000
So going to be app dot post, then pass in the endpoint that is the API and then the register next I'm

23
00:01:55,000 --> 00:01:56,320
going to be the callback.

24
00:01:56,320 --> 00:02:03,700
I have access to request response and as that and we are going to use async for this.

25
00:02:03,790 --> 00:02:09,100
So inside here I'm going to make use of try and catch.

26
00:02:09,979 --> 00:02:17,210
And for the meantime, let's send this JSON data because we are developing the API.

27
00:02:17,240 --> 00:02:25,840
That's why we are going to send JSON data either because or API, we need to send back JSON data format.

28
00:02:25,850 --> 00:02:33,380
So I provide the starters for this one and I will say success and I will need this one in the front

29
00:02:33,380 --> 00:02:33,950
end.

30
00:02:34,220 --> 00:02:37,550
As we move on, you better understand these properties.

31
00:02:37,580 --> 00:02:42,620
Next, I'm going to be the user and I'll provide as user registered.

32
00:02:44,620 --> 00:02:47,230
I start in case something goes wrong.

33
00:02:47,230 --> 00:02:52,300
Let's send rest, Jason, and we're going to sign the entire error.

34
00:02:52,300 --> 00:02:56,890
And we have a section where we are going to add our custom error handlers.

35
00:02:57,100 --> 00:03:00,220
All right, So now we have the first one for register.

36
00:03:00,220 --> 00:03:07,570
I can copy this one and let me collapse this one and I'll paste down here and change this one to log

37
00:03:07,570 --> 00:03:12,310
in and I'll change this one to log in also.

38
00:03:12,310 --> 00:03:15,250
And when I be as user, log in.

39
00:03:15,310 --> 00:03:19,060
So the same post method I could logs it.

40
00:03:19,540 --> 00:03:24,130
The next one is going to be the details about the user.

41
00:03:24,130 --> 00:03:33,550
So here is going to be as get an API, I'll provide dynamic ID, I'll start and here provide the dynamic

42
00:03:33,550 --> 00:03:40,090
ID and we are going to use this endpoint to find details about a user.

43
00:03:40,090 --> 00:03:45,070
So here as a single user or user details.

44
00:03:47,580 --> 00:03:49,290
And collapse it.

45
00:03:49,290 --> 00:03:50,880
And I'll copy this one.

46
00:03:50,880 --> 00:03:55,770
And down here I'll paste this one and change this one to profile.

47
00:03:57,600 --> 00:04:04,200
And then four slash ID and you're going to be asked to file for a slash ID.

48
00:04:04,500 --> 00:04:12,180
So these two endpoint single and profile, the first one is going to be the public, meaning that if

49
00:04:12,180 --> 00:04:19,680
a user is viewing a post, that person can view the creator of the post, but for the profile is going

50
00:04:19,680 --> 00:04:23,740
to be private, meaning when it belong to the creator only.

51
00:04:23,760 --> 00:04:29,820
So here when I get requests like y this US gets requests.

52
00:04:29,910 --> 00:04:37,660
So after that we are going to create one end point for uploading profile image.

53
00:04:37,680 --> 00:04:44,100
So here is going to be as put request because we are updating a user property.

54
00:04:44,100 --> 00:04:44,640
Right?

55
00:04:44,640 --> 00:04:51,330
So here need to provide users and I'll provide a profile upload.

56
00:04:53,670 --> 00:04:57,480
And here you need to provide the ID of the user.

57
00:04:57,480 --> 00:05:06,090
But as you move on, we will do away with the ID, but instead we will get the user ID from the root.

58
00:05:06,090 --> 00:05:08,790
For the meantime, let's maintain this.

59
00:05:09,090 --> 00:05:15,270
So let me rename this one as pull five photo upload to be more specific.

60
00:05:15,270 --> 00:05:20,040
So I'm going to copy this one and I'll paste it here.

61
00:05:20,460 --> 00:05:20,970
Sorry.

62
00:05:20,970 --> 00:05:29,250
It's supposed to be forward slash and then forward slash like that and like that.

63
00:05:29,250 --> 00:05:35,160
So next one is going to be uploading the cover image.

64
00:05:35,160 --> 00:05:40,200
So this one going to be put in here also as put.

65
00:05:41,990 --> 00:05:47,210
And he's going to be as cover photo upload.

66
00:05:49,240 --> 00:05:49,900
All right.

67
00:05:49,900 --> 00:05:57,760
So let me change the text here as user profile image upload.

68
00:05:58,120 --> 00:06:04,090
And for the cover, I'm going to be as user cover image upload.

69
00:06:08,600 --> 00:06:09,380
Right.

70
00:06:09,710 --> 00:06:15,710
The next one is going to be the updating the user password.

71
00:06:15,710 --> 00:06:17,750
So I'll copy this one.

72
00:06:18,350 --> 00:06:25,550
And down here, I would change this one to users and update password.

73
00:06:30,820 --> 00:06:34,390
And let me provide the same name here.

74
00:06:35,690 --> 00:06:37,130
As that.

75
00:06:38,760 --> 00:06:43,250
Going to be as use a password update.

76
00:06:48,460 --> 00:06:49,300
All right.

77
00:06:50,500 --> 00:06:53,290
The next one going to be the lockout.

78
00:06:53,290 --> 00:06:54,190
So.

79
00:06:55,960 --> 00:06:58,390
This one going to be Gates request.

80
00:06:58,390 --> 00:07:05,230
So here is going to be get an API users and then look out.

81
00:07:08,050 --> 00:07:09,520
As that.

82
00:07:09,700 --> 00:07:14,470
So I would change this one to look out.

83
00:07:15,640 --> 00:07:18,670
And then use that look out.

84
00:07:20,610 --> 00:07:21,360
Perfect.

85
00:07:21,510 --> 00:07:29,740
So here is going to be get so this other route that you may need for now in case we left some behind.

86
00:07:29,760 --> 00:07:30,390
Definitely.

87
00:07:30,390 --> 00:07:32,670
We will come back and then fix it.

88
00:07:32,670 --> 00:07:35,100
So now we are done with the user.

89
00:07:35,110 --> 00:07:37,410
So what about the post?

90
00:07:37,530 --> 00:07:45,810
So let's copy one of this ones and let's come back to post route and let's paste this one and change

91
00:07:45,810 --> 00:07:51,750
this one to post and here provide us post.

92
00:07:52,080 --> 00:07:56,310
And inside here it's going to be as post created.

93
00:07:59,560 --> 00:08:01,200
And let me collapse.

94
00:08:01,210 --> 00:08:03,400
So let me change this one to post.

95
00:08:07,410 --> 00:08:15,630
Let me copy this one down here, piece eight and change this one to fetch all So we're going to be get.

96
00:08:17,310 --> 00:08:18,650
And then post.

97
00:08:18,660 --> 00:08:26,790
So a difference here is going to be the HTTP method gets I'm going to be as post list.

98
00:08:27,270 --> 00:08:30,570
So let me collapse X and copy.

99
00:08:31,080 --> 00:08:33,130
And here I'm going to paste.

100
00:08:33,179 --> 00:08:44,730
Going to be a single voice slash colon ID and forced slash colon ID and going to be post details.

101
00:08:49,090 --> 00:08:56,670
Let me collapse it and copy this one and this one is going to be delete.

102
00:09:00,010 --> 00:09:08,890
Post and difference here is going to be the HTTP method as delete and post deleted.

103
00:09:09,580 --> 00:09:14,020
So let me collapse it and copy this one down here.

104
00:09:14,060 --> 00:09:15,520
Going to be updates.

105
00:09:15,520 --> 00:09:17,290
It's going to be as put.

106
00:09:17,860 --> 00:09:27,520
So here difference here is the HTTP method called puts and here as posts update it.

107
00:09:28,090 --> 00:09:28,810
All right.

108
00:09:28,810 --> 00:09:30,040
So now we have that one.

109
00:09:30,040 --> 00:09:37,300
Let's copy all this one for the post and let's paste here and our comments.

110
00:09:37,600 --> 00:09:38,020
All right.

111
00:09:38,020 --> 00:09:39,430
So let's start here.

112
00:09:39,460 --> 00:09:47,180
That is the comment here for creating it going to be as comments and select this one and press command

113
00:09:47,180 --> 00:09:49,360
D for multiple selection.

114
00:09:49,360 --> 00:09:55,510
I would change this one to comment and here as comments created.

115
00:09:56,440 --> 00:09:57,290
For this one.

116
00:09:57,310 --> 00:09:59,230
You don't need it to fetch or comment.

117
00:09:59,230 --> 00:10:00,670
So I remove that.

118
00:10:00,670 --> 00:10:06,670
I want to find a single comment, for example, if I want to update so I will need this one.

119
00:10:06,670 --> 00:10:13,720
I would change this one to comment and here as comments details.

120
00:10:16,130 --> 00:10:16,550
Right.

121
00:10:16,550 --> 00:10:19,130
Next one going to be the delete.

122
00:10:19,130 --> 00:10:25,220
So we are going to be as comments and here as comments deleted.

123
00:10:27,240 --> 00:10:29,400
And I can also update.

124
00:10:29,400 --> 00:10:31,950
So I would change this one to.

125
00:10:33,040 --> 00:10:33,840
Comments.

126
00:10:34,370 --> 00:10:39,940
Voice ID and the same as put in here as comment.

127
00:10:40,210 --> 00:10:40,930
All right.

128
00:10:40,930 --> 00:10:45,400
So these are the routes we need for our application.

129
00:10:45,550 --> 00:10:46,780
The next video.

130
00:10:46,810 --> 00:10:52,540
Let's go ahead and test the endpoint using the ten dot client extension.

