Limiters
Registering limiters
auth/auth_limiter.ts
export const otpLimiter = limiter.define('otp', () => {
return limiter.allowRequests(3).every('1 minute')
})
Using limiters
auth/auth_router.ts
router.post("otp/ask-otp", [OtpController, "askForOtp"]).as("otp.ask-otp").use(otpLimiter);
See more
If you want a context, like the user, you can use the ctx
parameter. See more on:
AdonisJS Rate Limiting (opens in a new tab)