1
00:00:00,420 --> 00:00:06,930
Beautiful, and once we're done with the set up next, I want to set up our two only roads so we have

2
00:00:06,930 --> 00:00:11,610
one fake one for log in or register and sign up.

3
00:00:11,790 --> 00:00:16,980
And please understand that, of course, in the following projects, there's going to be a huge distinction

4
00:00:17,460 --> 00:00:21,240
whether we are registering or we're actually just logging in.

5
00:00:21,330 --> 00:00:28,800
But in this case, we'll jam both of them together because our main concern is going to be that JWT

6
00:00:29,100 --> 00:00:30,450
or Jamestown were broken.

7
00:00:30,780 --> 00:00:36,600
And as a quick side note in the following videos, when I use term JWT, of course, I'm talking about

8
00:00:36,600 --> 00:00:37,890
the JSON Web token.

9
00:00:38,340 --> 00:00:44,050
Um, and basically what we want is to set up those two worlds and we already know how to do that.

10
00:00:44,050 --> 00:00:46,860
So, of course, we have the Roots folder in there.

11
00:00:46,860 --> 00:00:48,330
Eventually we'll have the router.

12
00:00:49,160 --> 00:00:54,250
And then we'll also have the controllers, so in this case, let's just start with controllers.

13
00:00:54,320 --> 00:00:59,840
I'm going to go here with Collins and effectively I'll set up both of these functions and I'll go with

14
00:00:59,840 --> 00:01:05,960
the sink because remember, we have the package that handles that, the async error.

15
00:01:05,990 --> 00:01:13,510
So we don't have to set up Guitry or our own middleware and we can simply go with rack and rest.

16
00:01:14,060 --> 00:01:17,960
And as far as the response will just go with the rest that I'm going to send.

17
00:01:18,320 --> 00:01:23,330
And here I'm just going to say fake login or register.

18
00:01:24,340 --> 00:01:30,010
And then, of course, the sign up and like I said, normally, of course, there's going to be a difference

19
00:01:30,250 --> 00:01:36,490
whether we're logging in or we're registering or in this case, we'll just mush all of them together

20
00:01:36,910 --> 00:01:38,740
and then we'll say we're out here.

21
00:01:39,370 --> 00:01:40,650
That's for the logging.

22
00:01:40,930 --> 00:01:46,220
And when it comes to dashboard, this is where we want to share that secret or authorized data.

23
00:01:46,570 --> 00:01:53,230
So let's just say here there's more and that will be equal again to, I think, rock and roll.

24
00:01:54,370 --> 00:01:59,530
And here, let's do it a little bit more interesting where I just want to set up some random number

25
00:01:59,530 --> 00:02:01,180
and I'll call this lucky number.

26
00:02:02,020 --> 00:02:08,380
And of course, that will be equal to math random, which is coming from the JavaScript and multiply

27
00:02:08,380 --> 00:02:16,150
this by, I don't know, maybe one hundred and then let's wrap everything in the math for and essentially

28
00:02:16,150 --> 00:02:22,520
we should get the random numbers between zero and hundred and nine once we set up the lucky number.

29
00:02:22,530 --> 00:02:24,450
Let's just go with the resident status.

30
00:02:25,270 --> 00:02:27,910
And of course, eventually this route will be protected.

31
00:02:27,920 --> 00:02:30,900
But of course, for the time being, we'll just go with the resident status.

32
00:02:30,910 --> 00:02:38,710
Two hundred and I don't say Jason will be sending back the object of, say, message here and eventually

33
00:02:38,710 --> 00:02:43,910
it's going to be the name of the user and therefore I'll place everything in right away in that string.

34
00:02:43,930 --> 00:02:51,220
But for now, since we don't have the user doesn't say John Doe and the other property on the object,

35
00:02:51,220 --> 00:02:52,660
he is going to be a secret.

36
00:02:53,320 --> 00:02:55,450
So let's say a comma secret.

37
00:02:55,780 --> 00:02:58,260
And again, we'll use the template string.

38
00:02:58,600 --> 00:03:04,240
And I say, here is your authorized data, your lucky number, and then of course, will access the

39
00:03:04,240 --> 00:03:04,660
variable.

40
00:03:04,960 --> 00:03:10,300
And once we have all of this in place, once we have the first string as well as the second one, a

41
00:03:10,300 --> 00:03:10,880
lucky number.

42
00:03:11,170 --> 00:03:13,210
Now, of course, we just want to export them.

43
00:03:13,480 --> 00:03:19,660
And I think for now I can just close the console as well as the sidebar and we'll just go with module

44
00:03:20,180 --> 00:03:20,830
exports.

45
00:03:21,160 --> 00:03:26,860
And of course, we're exporting the object and we're looking for two functions, login and dashboard.

46
00:03:27,280 --> 00:03:34,570
And it looks like I made a big old doozy where essentially I set up my code in the router instead of

47
00:03:34,570 --> 00:03:35,270
the controller.

48
00:03:35,590 --> 00:03:36,750
My apologies.

49
00:03:36,750 --> 00:03:43,540
So take all of this code, cut it out from the roots and you're actually looking for the controllers.

50
00:03:43,780 --> 00:03:47,650
We copy and paste and line back in or out.

51
00:03:47,650 --> 00:03:50,440
Of course, this is where we want to set up the router.

52
00:03:50,800 --> 00:03:56,620
So in here we're looking for Express, just like we did before we go with Require.

53
00:03:56,950 --> 00:03:59,290
We're looking for the express package, of course.

54
00:03:59,710 --> 00:04:06,640
Then we want to set up the routers of CONSED router is equal to express our router.

55
00:04:06,640 --> 00:04:08,760
We invoke it online.

56
00:04:08,770 --> 00:04:14,770
We're looking for both of the controller functions and those are login and dashboard and both of them

57
00:04:14,770 --> 00:04:16,440
are coming from the controllers.

58
00:04:16,990 --> 00:04:24,400
So if we're able to fix my bugs and essentially we want to go to levels up and line, we're looking

59
00:04:24,400 --> 00:04:25,020
for the man.

60
00:04:25,660 --> 00:04:31,510
And then once we have all of this in place, eventually there's going to be a middleware for authentication

61
00:04:31,510 --> 00:04:31,900
as well.

62
00:04:32,230 --> 00:04:35,910
But for the time being, we'll just go with a router and line in here.

63
00:04:35,920 --> 00:04:39,010
Let's go with Dashboard First Dashboard.

64
00:04:40,280 --> 00:04:45,950
And this is going to be a GETRUDE and simply pass in the dashboard controller.

65
00:04:46,490 --> 00:04:52,490
Now the login one is going to be a postman because of course, we want to get those user credentials,

66
00:04:52,790 --> 00:04:55,090
the user name, as well as the password.

67
00:04:55,430 --> 00:05:00,620
So we go here with the router vendor out, then forward slash login.

68
00:05:01,340 --> 00:05:05,720
And of course, in this case, we go with post method online.

69
00:05:05,720 --> 00:05:07,100
We'll pass in the login.

70
00:05:07,310 --> 00:05:13,910
And then the last thing we want to do is, of course, export this or module exports and we set it equal

71
00:05:13,910 --> 00:05:14,810
to the router.

72
00:05:15,350 --> 00:05:20,090
And then once we have all of this in place, we go back to the Appoggiaturas.

73
00:05:20,420 --> 00:05:22,720
We're looking for the main router.

74
00:05:23,150 --> 00:05:29,320
So I'm going to go above both the metalworks and I'll say your main router.

75
00:05:29,510 --> 00:05:31,760
Now, that is coming from my roots.

76
00:05:32,120 --> 00:05:37,240
So require and it's in the same folder essentially tomorrow.

77
00:05:37,700 --> 00:05:39,500
So we simply go with forward slash.

78
00:05:39,770 --> 00:05:47,840
We're looking for the roots and more specifically remain online where we have the middleware for not

79
00:05:47,840 --> 00:05:49,580
found one and all that above.

80
00:05:49,580 --> 00:05:51,890
It will just go with Abdala years.

81
00:05:52,230 --> 00:05:56,060
And again, what is going to be that route and point?

82
00:05:56,420 --> 00:06:01,640
Well, in my case, again, I'm going to go with API and then version one, because that's the setup

83
00:06:01,880 --> 00:06:04,880
that I have, of course, in The Postman.

84
00:06:05,060 --> 00:06:11,570
And then of course we'll just set up that every time we get a request on this route and point, we'll

85
00:06:11,570 --> 00:06:15,020
just go with main route or so ago, the main router.

86
00:06:15,020 --> 00:06:18,320
And of course, in the main router we have the dashboard.

87
00:06:18,590 --> 00:06:24,170
So that one will be API version one for its dashboard and then for the login.

88
00:06:24,470 --> 00:06:29,900
You already can imagine that it's going to be API version one and login.

89
00:06:30,170 --> 00:06:35,900
And once the basic controllers as well as the routes are in place now, of course, we can move on to

90
00:06:35,900 --> 00:06:36,950
our next task.

