BeginnerCoder

Lesson 17 — Rate limiting an endpoint

Too many requests

A rate limiter protects an endpoint (one URL of your API) from being called too often — by a bug or an attacker. The simplest one counts calls and refuses after a maximum. Real servers answer refused calls with status 429 Too Many Requests.

const hit = limiter(3);
hit(); hit(); hit(); hit();   // ok ok ok blocked

Why it matters: without limits, one script can slow the site down for everyone.

Want it another way?
Task

Finish limiter(): return "ok" while count < max (then count up), otherwise "blocked".

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with Node.js Foundations

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.