Skip to content

Commit

Permalink
Merge pull request #3646 from TheSpaceDevs/add-ratelimit
Browse files Browse the repository at this point in the history
feat: add rate-limit
  • Loading branch information
derkweijers authored Dec 13, 2024
2 parents ef83fc5 + 58a4761 commit f822635
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": [
{
"type": "debugpy",
"request": "launch",
"name": "Launch Django App",
"program": "${workspaceFolder}/src/manage.py",
"args": [
"runserver",
"0.0.0.0:8000"
],
"django": true
}
]
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dev-dependencies = [
"bandit[toml]>=1.7.9",
"commitizen>=4.0.0",
"coverage>=7.6.1",
"django-debug-toolbar>=4.4.6",
"django-filter-stubs>=0.1.3",
"djangorestframework-stubs[compatible-mypy]>=3.14.0,<3.15.0",
"mypy>=1.7.0,<1.8.0",
Expand Down
12 changes: 12 additions & 0 deletions src/snapy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@
"health_check.contrib.s3boto3_storage",
"health_check.contrib.redis",
"graphene_django",
"debug_toolbar",
]

MIDDLEWARE = [
"debug_toolbar.middleware.DebugToolbarMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
Expand Down Expand Up @@ -188,6 +190,12 @@
"DEFAULT_FILTER_BACKENDS": ["django_filters.rest_framework.DjangoFilterBackend"],
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.NamespaceVersioning",
'DEFAULT_THROTTLE_CLASSES': [
'rest_framework.throttling.AnonRateThrottle',
],
'DEFAULT_THROTTLE_RATES': {
'anon': '5/second',
}
}

SPECTACULAR_SETTINGS = {
Expand Down Expand Up @@ -230,3 +238,7 @@
"LOCATION": env.str("REDIS_URL", "redis://localhost:6379"),
}
}

INTERNAL_IPS = [
"127.0.0.1",
]
3 changes: 2 additions & 1 deletion src/snapy/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""

from debug_toolbar.toolbar import debug_toolbar_urls
from django.contrib import admin
from django.urls import include, re_path
from django.views.decorators.csrf import csrf_exempt
Expand All @@ -33,4 +34,4 @@
# Non v4 URLs
re_path(r"health/", include("health_check.urls")),
re_path(r"admin/", admin.site.urls),
]
] + debug_toolbar_urls()
17 changes: 16 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f822635

Please sign in to comment.