0
0
Expressframework~10 mins

Rate limiting with express-rate-limit - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the express-rate-limit package.

Express
const rateLimit = require('[1]');
Drag options to blanks, or click blank then click option'
Aexpress-rate-limit
Bexpress
Crate-limit
Dexpress-rate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'express' instead of 'express-rate-limit'.
Using incomplete or incorrect package names.
2fill in blank
medium

Complete the code to create a rate limiter that allows 100 requests per 15 minutes.

Express
const limiter = rateLimit({ windowMs: 15 * 60 * 1000, max: [1] });
Drag options to blanks, or click blank then click option'
A100
B200
C50
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number too low or too high than 100.
Confusing the time window with max requests.
3fill in blank
hard

Fix the error in applying the rate limiter middleware to all routes.

Express
app.use([1]);
Drag options to blanks, or click blank then click option'
Alimiter()
BrateLimit()
CrateLimiter
Dlimiter
Attempts:
3 left
💡 Hint
Common Mistakes
Calling the limiter as a function instead of passing it.
Using undefined variables.
4fill in blank
hard

Fill both blanks to create a rate limiter that sends a custom message when limit is exceeded.

Express
const limiter = rateLimit({ windowMs: 10 * 60 * 1000, max: 50, [1]: (req, res) => { res.status(429).send([2]); } });
Drag options to blanks, or click blank then click option'
Ahandler
B'Too many requests, please try again later.'
Cmessage
D'Request limit reached.'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'message' instead of 'handler' for the function.
Passing the message as an option instead of inside the handler.
5fill in blank
hard

Fill all three blanks to create a rate limiter with a 5-minute window, max 20 requests, and a custom message.

Express
const limiter = rateLimit({ windowMs: [1] * 60 * 1000, max: [2], handler: (req, res) => { res.status(429).send([3]); } });
Drag options to blanks, or click blank then click option'
A5
B20
C'You have exceeded the request limit, please wait.'
D'Limit exceeded, try again later.'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up windowMs and max values.
Using incorrect message strings.