1
00:00:00,300 --> 00:00:05,250
Beautiful, and once we're done setting up register functionality before we do the same thing with a

2
00:00:05,250 --> 00:00:11,550
log in one, I also want to install one more package and the package name is going to be Morgan, which

3
00:00:11,550 --> 00:00:15,730
is a blogger middleware and why it's very useful.

4
00:00:15,750 --> 00:00:20,070
Well, because as we start setting up more outs and controllers.

5
00:00:21,040 --> 00:00:27,580
It's very cool to see what is the route that we're hearing, as well as the method and the status code.

6
00:00:27,880 --> 00:00:32,560
Yeah, with just one register, I mean, we clearly kind of knew that.

7
00:00:32,560 --> 00:00:38,020
But again, the more routes and controllers you have, it becomes very, very useful.

8
00:00:38,320 --> 00:00:41,890
And pretty much Morgan has become a standard for that.

9
00:00:42,190 --> 00:00:45,670
Now, if you want to find out more info, just please follow this link.

10
00:00:46,660 --> 00:00:47,830
The setup is pretty typical.

11
00:00:47,830 --> 00:00:54,400
Again, we go with AMPM I Morgan, so install the package version where you're required and then we

12
00:00:54,400 --> 00:00:55,930
want to stick it in the middle where.

13
00:00:56,850 --> 00:01:03,750
And we want to pass in one of the options, so timing is going to be probably one of the smallest ones,

14
00:01:03,750 --> 00:01:06,930
basically you have the least amount of info.

15
00:01:07,200 --> 00:01:12,180
And if you want to find out more options, you can pass in, just navigate to the docks and you'll be

16
00:01:12,180 --> 00:01:14,310
able to find all of the info.

17
00:01:14,460 --> 00:01:16,410
So let's keep on scrolling and notice here.

18
00:01:16,680 --> 00:01:22,530
We're going to go with Dev because they will also add some colors here, and we'll be able to see the

19
00:01:22,530 --> 00:01:24,420
method, the URL status.

20
00:01:24,480 --> 00:01:26,940
And you can read the rest.

21
00:01:27,480 --> 00:01:37,020
Now, one thing that will add here is the condition where I only want to do that if my note environment

22
00:01:37,380 --> 00:01:38,970
is not equal to production.

23
00:01:39,180 --> 00:01:46,860
And yes, once we push this up to production, once we host this on Roku, Heroku will set this node

24
00:01:46,980 --> 00:01:48,510
on the score in V.

25
00:01:48,630 --> 00:01:51,300
So note an environment equal to production.

26
00:01:51,510 --> 00:01:55,260
And once they're in production, while there's really no need to log that correct.

27
00:01:55,620 --> 00:02:02,370
So say, if note environment is not equal to production, yes, then I want to use abduct use used.

28
00:02:02,370 --> 00:02:03,360
So that's my mentor.

29
00:02:03,570 --> 00:02:09,000
And then I want to pass in the Morgan, which I just imported, and then I'm going to go with that option

30
00:02:09,000 --> 00:02:11,940
because again, it just adds nice colors.

31
00:02:12,240 --> 00:02:14,970
So let's start by setting up the install.

32
00:02:16,050 --> 00:02:17,430
So I'm going to stop the server.

33
00:02:18,150 --> 00:02:19,140
Clear everything.

34
00:02:20,060 --> 00:02:23,270
And then let's go with npm install, OK, beautiful.

35
00:02:23,660 --> 00:02:29,780
Then let's start the server right away because it will take a little bit of time and then back in the

36
00:02:29,780 --> 00:02:31,640
server, just let's import the Morgan.

37
00:02:32,030 --> 00:02:35,270
And I think I'm going to do that right after express async.

38
00:02:35,540 --> 00:02:36,860
So important.

39
00:02:37,370 --> 00:02:45,320
When Morgan from and of course, the Morgan one version, let's keep on going online.

40
00:02:45,320 --> 00:02:51,710
I'm going to do that above express Jason where I'll set up my condition and I'll see if process that

41
00:02:51,710 --> 00:02:52,640
interview again.

42
00:02:52,940 --> 00:02:59,630
Narrowed Environment Variable, which is node, underscore the even if it's not equal to production,

43
00:03:00,170 --> 00:03:04,190
it's not equal to production when awesome when we want to go with adult use.

44
00:03:04,340 --> 00:03:07,700
That's the middleware online will pass in Morgan.

45
00:03:08,090 --> 00:03:14,420
When I said in my case, the option I'm going to go with is Dev, let's save it and I'm going to swing

46
00:03:14,420 --> 00:03:17,840
back to the postman and I'll set up similar questions.

47
00:03:17,840 --> 00:03:25,070
So let's start with the register, but I'm looking for a 400 response because I'm going to try to register

48
00:03:25,370 --> 00:03:27,770
with already existing email.

49
00:03:28,040 --> 00:03:30,440
So at Senate, we get back 400.

50
00:03:30,890 --> 00:03:36,200
But when I want to showcase is the fact that in my console, I'll see this one.

51
00:03:37,280 --> 00:03:38,060
I'll say the method.

52
00:03:38,540 --> 00:03:42,710
I'll see the path and also see the response.

53
00:03:43,040 --> 00:03:50,900
And again, this is very useful as you start having more routes and controllers because by way, it's

54
00:03:50,900 --> 00:03:52,700
much more easier to see what's happening.

55
00:03:52,940 --> 00:04:00,890
It's very easy to make a small typo somewhere, let's say, on a front end or even in the postman where

56
00:04:00,890 --> 00:04:01,910
you're hitting the route.

57
00:04:02,450 --> 00:04:08,330
And actually, the method is incorrect like you just saw with the patch one where I was like, Hey,

58
00:04:08,330 --> 00:04:09,350
listen, what's the problem?

59
00:04:09,650 --> 00:04:13,250
And it's actually the method is very useful.

60
00:04:13,580 --> 00:04:16,940
So let me also showcase that we have my home routes.

61
00:04:16,940 --> 00:04:23,000
So if I'm going to go here to the postman and if I'll just set up a dummy route, for example, here

62
00:04:23,000 --> 00:04:24,110
I have the URL.

63
00:04:24,200 --> 00:04:30,470
If I send it, I'm going to get back on message API and again in my console also get.

64
00:04:31,130 --> 00:04:37,760
So that means it's a Geraldton API version one and then response is 200.

65
00:04:37,880 --> 00:04:43,220
And once we have the Morgan in place now, we can start setting up of the log in functionality.

