1
00:00:00,330 --> 00:00:00,690
All right.

2
00:00:00,990 --> 00:00:08,100
And once our basic server is running with our awesome, well, context, I'll set up some mental words

3
00:00:08,100 --> 00:00:09,990
that we use throughout the project.

4
00:00:10,260 --> 00:00:13,110
And I'm talking about the not found middleware and armament.

5
00:00:13,470 --> 00:00:15,030
I'm going to start with non-iPhone.

6
00:00:15,480 --> 00:00:21,630
So essentially, if I'm getting some kind of request for a resource that doesn't exist, for example,

7
00:00:21,640 --> 00:00:28,200
for its like law, the moment I'm getting the default express not found response, but I want to turn

8
00:00:28,320 --> 00:00:36,060
that around and set up a custom one where we can decide wherever we want to send back and the steps

9
00:00:36,060 --> 00:00:37,980
are going to be following where in the road.

10
00:00:38,340 --> 00:00:43,050
So in the same place where we have the server, so please don't set this one up in a client.

11
00:00:43,500 --> 00:00:48,180
We want to go with middleware folder and then there will create a not found yes.

12
00:00:48,990 --> 00:00:56,250
And instead of the file, set up a function and we'll just go with some kind of for a for response.

13
00:00:56,610 --> 00:00:58,860
In my case, I'm going to go with real does not exist.

14
00:00:59,400 --> 00:01:05,129
So whereas that status for 04 and then that's and then I'll pass in the text.

15
00:01:05,670 --> 00:01:09,240
I want to import that in the server Gerrit, meaning the file.

16
00:01:09,600 --> 00:01:16,860
But since we're using modules, the year six modules in node line, we need to remember we need to use

17
00:01:17,220 --> 00:01:20,250
Dart just extension for two files.

18
00:01:20,760 --> 00:01:23,940
So we didn't have to do that when we were using common just set up.

19
00:01:24,970 --> 00:01:29,260
But if you do use, you know, six manuals, yes, you'll have to do that.

20
00:01:29,620 --> 00:01:34,690
And then I want to pledge that after the homeland because basically I want to catch all the requests

21
00:01:35,080 --> 00:01:38,780
that do not match any of our current drought.

22
00:01:38,790 --> 00:01:41,650
So think of this as a fallback.

23
00:01:41,860 --> 00:01:43,210
So let's start working on that.

24
00:01:43,210 --> 00:01:50,350
And probably the toughest one for me will be spelling middleware, because that's usually where I make

25
00:01:50,350 --> 00:01:51,280
a bunch of bugs.

26
00:01:51,290 --> 00:01:55,380
So middleware, hopefully that is correct and learn.

27
00:01:56,010 --> 00:01:59,190
I'm going to go with not hyphen found.

28
00:01:59,230 --> 00:01:59,590
Yes.

29
00:02:00,140 --> 00:02:02,110
And let's set up that function.

30
00:02:02,660 --> 00:02:07,900
I'm going to go with an aunt from Minnesota, and you'll see in a second one basically is because in

31
00:02:07,900 --> 00:02:08,710
the server.

32
00:02:09,910 --> 00:02:14,290
I like those explicit names because that tells me exactly what is happening.

33
00:02:14,320 --> 00:02:15,700
Again, that is just my preference.

34
00:02:16,030 --> 00:02:17,380
You don't have to do that.

35
00:02:17,800 --> 00:02:25,690
So let me go back here and not found that I'm going to go with not found and middleware, and I will

36
00:02:25,690 --> 00:02:27,370
use the auto import for this case.

37
00:02:27,880 --> 00:02:31,990
So I'm going to go with the recognize since this is going to have access to it.

38
00:02:32,260 --> 00:02:33,280
It's going to be Ahmadullah.

39
00:02:33,640 --> 00:02:36,430
And then let's just go with that status.

40
00:02:36,940 --> 00:02:39,130
Status will be for, of course, that doesn't change.

41
00:02:39,130 --> 00:02:47,320
But as far as the message, and let's just say send and I believe I went with without does not exist

42
00:02:47,530 --> 00:02:47,810
much.

43
00:02:47,820 --> 00:02:48,380
Save it.

44
00:02:49,090 --> 00:02:58,450
And then what I want to do is to set up export default, export default, and I'm working for not found

45
00:02:58,450 --> 00:02:58,930
middleware.

46
00:02:59,380 --> 00:03:02,470
Let's say it back in the server.

47
00:03:03,370 --> 00:03:04,300
Here's what I want to do.

48
00:03:04,900 --> 00:03:10,480
I want to go above the ground and I'm looking for a comment here.

49
00:03:10,480 --> 00:03:12,130
So I'll say middleware.

50
00:03:13,410 --> 00:03:15,930
And then let's just look for are not found one.

51
00:03:16,210 --> 00:03:18,210
And like I said, we can use the auto import.

52
00:03:18,480 --> 00:03:19,320
So we'll go here.

53
00:03:19,650 --> 00:03:23,700
Just keep in mind one thing where you will have to that jazz.

54
00:03:24,120 --> 00:03:27,360
So for now, I'm not going to add it just to showcase what happens.

55
00:03:27,870 --> 00:03:30,090
And I'm going to place my abductors.

56
00:03:30,270 --> 00:03:31,580
So I'm using the middle way.

57
00:03:31,920 --> 00:03:34,140
And essentially, when I use, I've not use.

58
00:03:34,740 --> 00:03:39,270
This just signals that I'm looking for all the TP methods.

59
00:03:39,810 --> 00:03:43,770
So what I do is a get one poached one patch one or whatever.

60
00:03:44,190 --> 00:03:50,340
And the same goes for or mother died as a home root words like hello or whatever.

61
00:03:50,560 --> 00:03:51,900
And that's why I place it after death.

62
00:03:52,290 --> 00:03:53,760
So express first.

63
00:03:54,150 --> 00:04:00,390
It's trying to match the request to all the routes that I have, meaning currently I only have one and

64
00:04:00,400 --> 00:04:00,810
one.

65
00:04:01,050 --> 00:04:08,070
If none of them match, then we go here with I'm not used and we serve are not, found Miller.

66
00:04:08,460 --> 00:04:09,630
So let me save it.

67
00:04:10,800 --> 00:04:14,520
Like I just said, we're going to have a big, fat error.

68
00:04:14,530 --> 00:04:14,840
Why?

69
00:04:15,210 --> 00:04:17,790
Well, because we have kind of find the module.

70
00:04:18,329 --> 00:04:19,470
Did you mean import?

71
00:04:19,470 --> 00:04:21,390
And I noticed this little address.

72
00:04:21,690 --> 00:04:24,930
So therefore I'm going to go here with that jazz.

73
00:04:25,410 --> 00:04:26,580
Let's move it down here.

74
00:04:27,450 --> 00:04:31,590
And then also what I do is basically take this name and then place it over here.

75
00:04:31,890 --> 00:04:33,290
Now again, you don't have to do that.

76
00:04:33,300 --> 00:04:37,500
It just saves a little bit of typing because in this case I typed it twice.

77
00:04:37,560 --> 00:04:43,620
Now, in my opinion, it's not a big deal, but I know that some people like to save time on that.

78
00:04:43,950 --> 00:04:47,280
And with this in place now, I can go here and refresh.

79
00:04:47,850 --> 00:04:53,910
And what do you know now I have root does not exist so could clearly see that are not found.

80
00:04:53,910 --> 00:04:55,530
Middleware is working.

