add basic rate limiting

This commit is contained in:
2025-07-01 11:38:38 -04:00
parent 1991e5b31b
commit c3f753a4f0
9 changed files with 64 additions and 20 deletions

View File

@ -1,6 +1,7 @@
import os
import aiosqlite as sqlite3
from fastapi import FastAPI
from fastapi import FastAPI, Depends
from fastapi_throttle import RateLimiter
from fastapi.responses import JSONResponse
from typing import Optional, LiteralString, Union
from .constructors import ValidShowEpisodeLineRequest, ValidShowEpisodeListRequest
@ -24,7 +25,9 @@ class Transcriptions(FastAPI):
for endpoint, handler in self.endpoints.items():
app.add_api_route(
f"/{endpoint}", handler, methods=["POST"], include_in_schema=True
f"/{endpoint}", handler,
methods=["POST"], include_in_schema=True,
dependencies=[Depends(RateLimiter(times=2, seconds=2))]
)
async def get_episodes_handler(