All right.
And once our basic server is running with our awesome, well, context, I'll set up some mental words
that we use throughout the project.
And I'm talking about the not found middleware and armament.
I'm going to start with non-iPhone.
So essentially, if I'm getting some kind of request for a resource that doesn't exist, for example,
for its like law, the moment I'm getting the default express not found response, but I want to turn
that around and set up a custom one where we can decide wherever we want to send back and the steps
are going to be following where in the road.
So in the same place where we have the server, so please don't set this one up in a client.
We want to go with middleware folder and then there will create a not found yes.
And instead of the file, set up a function and we'll just go with some kind of for a for response.
In my case, I'm going to go with real does not exist.
So whereas that status for 04 and then that's and then I'll pass in the text.
I want to import that in the server Gerrit, meaning the file.
But since we're using modules, the year six modules in node line, we need to remember we need to use
Dart just extension for two files.
So we didn't have to do that when we were using common just set up.
But if you do use, you know, six manuals, yes, you'll have to do that.
And then I want to pledge that after the homeland because basically I want to catch all the requests
that do not match any of our current drought.
So think of this as a fallback.
So let's start working on that.
And probably the toughest one for me will be spelling middleware, because that's usually where I make
a bunch of bugs.
So middleware, hopefully that is correct and learn.
I'm going to go with not hyphen found.
Yes.
And let's set up that function.
I'm going to go with an aunt from Minnesota, and you'll see in a second one basically is because in
the server.
I like those explicit names because that tells me exactly what is happening.
Again, that is just my preference.
You don't have to do that.
So let me go back here and not found that I'm going to go with not found and middleware, and I will
use the auto import for this case.
So I'm going to go with the recognize since this is going to have access to it.
It's going to be Ahmadullah.
And then let's just go with that status.
Status will be for, of course, that doesn't change.
But as far as the message, and let's just say send and I believe I went with without does not exist
much.
Save it.
And then what I want to do is to set up export default, export default, and I'm working for not found
middleware.
Let's say it back in the server.
Here's what I want to do.
I want to go above the ground and I'm looking for a comment here.
So I'll say middleware.
And then let's just look for are not found one.
And like I said, we can use the auto import.
So we'll go here.
Just keep in mind one thing where you will have to that jazz.
So for now, I'm not going to add it just to showcase what happens.
And I'm going to place my abductors.
So I'm using the middle way.
And essentially, when I use, I've not use.
This just signals that I'm looking for all the TP methods.
So what I do is a get one poached one patch one or whatever.
And the same goes for or mother died as a home root words like hello or whatever.
And that's why I place it after death.
So express first.
It's trying to match the request to all the routes that I have, meaning currently I only have one and
one.
If none of them match, then we go here with I'm not used and we serve are not, found Miller.
So let me save it.
Like I just said, we're going to have a big, fat error.
Why?
Well, because we have kind of find the module.
Did you mean import?
And I noticed this little address.
So therefore I'm going to go here with that jazz.
Let's move it down here.
And then also what I do is basically take this name and then place it over here.
Now again, you don't have to do that.
It just saves a little bit of typing because in this case I typed it twice.
Now, in my opinion, it's not a big deal, but I know that some people like to save time on that.
And with this in place now, I can go here and refresh.
And what do you know now I have root does not exist so could clearly see that are not found.
Middleware is working.