Security
Last updated
Was this helpful?
Last updated
Was this helpful?
This is too often overlooked or completely ignored. But just a few lines of code can make your app much harder to break.
helps you secure your Express apps by setting various HTTP headers.
Add an API rate limit to reduce the number of actions and protect from DDoS and brute force attacks.
Enforce HTTPS
Start protecting your app with helmet
We are going to create a new folder middlewares
and add RateLimiter.ts
to it.
We can now use this middleware in app.ts
.
The number of requests is now limited to 10 per seconds. Go ahead an experiment with higher numbers to see if you will get rejected.
Or instead, we can also write a test for this:
The library helps us keep track of requests count.
branch available on GitHub.