

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: DoS
incomplete
2: Rate Limiting
incomplete
3: Protecting Auth from Abuse
incomplete
4: Throttling Requests
incomplete
5: Queuing Work
incomplete
6: Resource Limits
incomplete
7: Timeouts
incomplete
8: Usage Quotas
incomplete
9: DDoS
incomplete
10: Mitigating DDoS
incomplete
11: Bot Detection
incomplete
12: CAPTCHA
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Rate limiting controls how often a client can call your API. Resource limits control how much work a single request can demand. For example:
I used to do a lot of work with the Facebook and Instagram APIs, and their limits were based on request processing time. One complex query can be 100x more expensive than ten simple ones!
HTTP servers should enforce a maximum request body size. Express's JSON parser defaults to 100 KB, but you should choose an explicit limit for your app:
app.use(express.json({ limit: "100kb" }));
File uploads need their own limits. With multer, you can limit both file size and count:
import multer from "multer";
const upload = multer({
limits: {
fileSize: 5 * 1024 * 1024, // 5 MB
files: 1,
},
});
Keep in mind that a tiny compressed file can still expand into gigabytes, and a small input to an evil regex can burn through your server's CPU. Limit the resource that can actually be exhausted.
Bearly Secure accepts request bodies and file uploads of any size, and its public product queries can return an unbounded number of rows.
Complete the app's per-request resource limits.
With Bearly Secure still running, run and submit the CLI tests from the project root.