1
00:00:00,140 --> 00:00:00,590
All right.

2
00:00:00,590 --> 00:00:03,200
And up next, let's set up our controllers.

3
00:00:03,200 --> 00:00:07,250
So we're looking for register and login controller.

4
00:00:07,250 --> 00:00:09,860
And also we want to set up the router.

5
00:00:10,040 --> 00:00:15,860
And this is the case where I encourage you to stop the video and try to set it up yourself.

6
00:00:15,860 --> 00:00:17,810
So again, you're looking for two controllers.

7
00:00:17,810 --> 00:00:20,000
You want to set up the router.

8
00:00:20,000 --> 00:00:27,050
In my case, I'm going to call this auth router and the full path is going to be API version one and

9
00:00:27,050 --> 00:00:27,710
auth.

10
00:00:27,710 --> 00:00:32,360
And then of course the user either goes to register or log in.

11
00:00:32,360 --> 00:00:39,080
So if you're interested, stop the video and resume once you're ready to compare the results.

12
00:00:39,110 --> 00:00:40,670
Okay, so let's get started.

13
00:00:40,670 --> 00:00:43,400
In my case, I'm going to go to Controllers folder.

14
00:00:43,640 --> 00:00:46,430
I'm looking for auth controller.

15
00:00:47,690 --> 00:00:48,550
James.

16
00:00:49,590 --> 00:00:52,140
And we want to set up those two functions.

17
00:00:52,140 --> 00:00:59,130
So export const, register, it's going to be async, so we might as well set it up.

18
00:00:59,130 --> 00:01:02,220
Right now it's going to have req and res.

19
00:01:02,880 --> 00:01:04,650
That also stays the same.

20
00:01:04,650 --> 00:01:07,470
And for now let's just go with res.send and.

21
00:01:08,300 --> 00:01:10,040
Let's go with the register here.

22
00:01:10,250 --> 00:01:10,610
Okay.

23
00:01:10,610 --> 00:01:11,420
Beautiful.

24
00:01:12,130 --> 00:01:14,320
Then we want to copy and paste this.

25
00:01:15,750 --> 00:01:17,490
And of course, change it around.

26
00:01:17,490 --> 00:01:18,240
So.

27
00:01:19,220 --> 00:01:21,200
Register is going to be a login.

28
00:01:21,560 --> 00:01:25,460
Then let's create a new router.

29
00:01:26,200 --> 00:01:30,610
So in this case, I'm going to call this auth router.

30
00:01:32,390 --> 00:01:36,890
JS And let's start by importing the router from Express.

31
00:01:37,470 --> 00:01:41,490
Now, of course, if you want, you can copy and paste and just change the values.

32
00:01:41,490 --> 00:01:44,040
But in my case, I'll start everything from scratch.

33
00:01:44,580 --> 00:01:52,350
We're looking for login and register and both of them are coming from the controllers.

34
00:01:52,620 --> 00:01:59,160
So let's go here to auth controller, let's add JS, Otherwise we'll have some bugs.

35
00:01:59,160 --> 00:02:01,140
We want to create the router.

36
00:02:01,230 --> 00:02:02,100
And you know what?

37
00:02:02,100 --> 00:02:04,500
Actually let me move this down.

38
00:02:04,500 --> 00:02:09,570
So this is going to be an import for router and then I'll have my own imports.

39
00:02:09,660 --> 00:02:13,380
So router is equal to router.

40
00:02:13,560 --> 00:02:17,880
Let's invoke this one and let's set up the two routes.

41
00:02:17,910 --> 00:02:22,430
Now this is the case where I will go with router dot and then post.

42
00:02:22,440 --> 00:02:27,150
Basically, I'm not going to go with the router dot route since I'm not going to change anything.

43
00:02:27,690 --> 00:02:31,770
Remember we had two approaches, so now I'm going to use the first one.

44
00:02:31,770 --> 00:02:32,820
So router post.

45
00:02:32,820 --> 00:02:39,490
So this is going to be a post route where it's going to go to a register here and then which controller

46
00:02:39,490 --> 00:02:44,670
we want to use of course the register one, and then we want to change this and around.

47
00:02:44,680 --> 00:02:50,680
So this will be a login one and make sure to export our router.

48
00:02:51,820 --> 00:02:54,460
And we're looking for default one, of course.

49
00:02:54,880 --> 00:02:57,550
So we're going to go with export default and router.

50
00:02:57,700 --> 00:03:01,300
Then at the very end, we want to go to a server.

51
00:03:01,480 --> 00:03:04,240
Then I want to look for my router import.

52
00:03:04,540 --> 00:03:05,860
So we're here.

53
00:03:06,640 --> 00:03:08,970
Basically, we just want to change some things around.

54
00:03:08,980 --> 00:03:11,080
So this will be auth router.

55
00:03:12,550 --> 00:03:15,440
And it's coming from the auth.

56
00:03:16,530 --> 00:03:17,580
Router file.

57
00:03:17,610 --> 00:03:19,500
Then let's keep on moving.

58
00:03:19,740 --> 00:03:22,050
Notice here API version jobs.

59
00:03:22,170 --> 00:03:26,040
So the base URL is going to be a little bit different.

60
00:03:26,370 --> 00:03:27,510
It's going to be auth.

61
00:03:29,440 --> 00:03:32,190
And we're looking for auth router.

62
00:03:32,200 --> 00:03:35,380
So now let's navigate to Thunder client.

63
00:03:36,750 --> 00:03:38,940
We're looking for collections recording one.

64
00:03:38,940 --> 00:03:43,200
At least in my case, I want to create a new folder.

65
00:03:44,020 --> 00:03:46,600
And in this case, I'm going to call this author out.

66
00:03:48,440 --> 00:03:54,260
And here we'll create one for register and one for login one.

67
00:03:54,410 --> 00:03:56,840
So let's create a new request.

68
00:03:57,780 --> 00:04:00,870
So call this a register user.

69
00:04:01,840 --> 00:04:03,630
Not going to be a get request.

70
00:04:03,630 --> 00:04:05,910
It's going to be a post request.

71
00:04:06,780 --> 00:04:09,090
For now, let's just use the URL.

72
00:04:10,200 --> 00:04:14,160
Remember that's our global one, then auth and then a register.

73
00:04:15,040 --> 00:04:15,900
Let's send.

74
00:04:15,910 --> 00:04:18,279
And if everything is correct, we should see.

75
00:04:18,959 --> 00:04:21,450
Register in response.

76
00:04:21,720 --> 00:04:24,180
And pretty much we want to duplicate this one.

77
00:04:24,940 --> 00:04:27,140
And we just want to change some values here.

78
00:04:27,160 --> 00:04:29,050
First of all, I want to rename it.

79
00:04:29,350 --> 00:04:30,790
We're going to go with.

80
00:04:31,520 --> 00:04:32,900
Register user.

81
00:04:34,530 --> 00:04:36,660
Or I'm sorry, we want to go with login user.

82
00:04:36,660 --> 00:04:37,320
My bad.

83
00:04:38,330 --> 00:04:42,440
And then in here the method is still post, so that doesn't change.

84
00:04:42,440 --> 00:04:44,600
But of course the URL is a little bit different.

85
00:04:44,600 --> 00:04:50,990
So now we want to log in and if everything is correct, we should see a login in response.

86
00:04:51,170 --> 00:04:54,560
And with this in place we can move on to the next step.

