And when it comes to express right limit, we have few options if you want, you can set it up for the
entire application.
And basically, the syntax would be something like this where you grab the package.
So express rate limit set up some kind of variable and then you want to invoke it.
And in now you pass in the object with the properties.
So and here are the two most important ones are how many requests in how long.
So if you want to go with 100 requests per 15 minutes, this is the code.
And essentially they set it up like this because one second is thousand milliseconds.
So this is going to be one minute and then times 15, this is going to be 15 minutes.
So of course, if you want to change that power, that is up to you.
And again, how many requests per that time in this case, 15 minutes.
And then you just set it up over here, notice.
You don't need to invoke it.
Just assign it to a variable and you push it in the middle where again, I'm not yours.
And you can definitely do so in the server.
So essentially, just like we set up rush stuff the libraries.
However, in this case, I'll show you the alternative where we can add it just for specific out.
And in my case, I'm going to add it only to register and log in.
That's it.
Again, let me repeat, if you want to set it up for your entire application, you can definitely do
show.
But in my case, I'm only going to add it to two rounds.
So let me navigate back to my application.
I'm looking for routes folder one specifically all throughout.
And the first thing that I want to do is grab that rate limiter.
So that's the variable I'll set up.
So rate and then limit are not as equal from a we go with express and rate limit one.
Once we have that one place and set up the variable.
So in my case, that's going to be API limits are not as equal to rate limiter.
Let's pass in the object.
And in my case, I'm going to go with window and seconds and I'm going to keep the same pattern basically
15 minutes or 15 times 60 times a thousand.
And I don't think that I need to repeat why we use these numbers, and I'll just add a comma here and
also accept the comment 15 minutes.
Now I also want to add how many requests.
And in my case, I'm going to go with them.
So in 15 minutes, Max, you can have 10 requests from that IP address.
And lastly, we can set up the custom message.
So just to showcase that we can go with message property and I'm going to go to many requests from this
IP.
Please try again after 15 minutes.
And once that is in place now, we just want to take this API limiter and place it in the round where
we want to use it.
So in my case, that is going to be for register and log in.
So let's go over here, say API limiter, comma, and the same thing is going to be over here for too
long an API limiter and we're going to go now for these two are out.
There's going to be a fan request max in 15 minutes and once that is exceeded, then we get back the
error message.