16 lines
475 B
TypeScript
16 lines
475 B
TypeScript
|
/**
|
||
|
* Define HTTP limiters
|
||
|
*
|
||
|
* The "limiter.define" method creates an HTTP middleware to apply rate limits on a route or a group of routes. Feel free to define as many throttle middleware as needed.
|
||
|
*/
|
||
|
|
||
|
import app from "@adonisjs/core/services/app"
|
||
|
import limiter from "@adonisjs/limiter/services/main"
|
||
|
|
||
|
export const throttle = limiter.define("global", () => {
|
||
|
if (app.inTest) {
|
||
|
return limiter.noLimit()
|
||
|
}
|
||
|
return limiter.allowRequests(120).every("1 minute")
|
||
|
})
|