From e848cf8ad0f35064456957afed3e7cac6e2dd768 Mon Sep 17 00:00:00 2001 From: alireza Date: Thu, 28 Nov 2024 20:27:25 +0330 Subject: [PATCH] add throttling --- src/api/urls.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/urls.py b/src/api/urls.py index f7b7814..2e949a2 100644 --- a/src/api/urls.py +++ b/src/api/urls.py @@ -9,8 +9,12 @@ from .info_api import router as info_router from ninja.errors import ValidationError,AuthenticationError from .utils import api_response +from ninja.throttling import AnonRateThrottle, AuthRateThrottle -api = NinjaExtraAPI(title='PersianCCBooks',docs=Swagger()) +api = NinjaExtraAPI(title='PersianCCBooks',docs=Swagger(),throttle=[ + AnonRateThrottle('5/s'), + AuthRateThrottle('20/s'), + ]) # jwt controler api.register_controllers(NinjaJWTDefaultController)