This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
wikipedia-game-solver/apps/api/src/start/limiter.ts

16 lines
475 B
TypeScript
Raw Normal View History

2024-08-12 15:13:24 +02:00
/**
* 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")
})