WIP: additional radio stations
This commit is contained in:
@ -71,14 +71,21 @@ class LyricSearch(FastAPI):
|
||||
)
|
||||
|
||||
for endpoint, handler in self.endpoints.items():
|
||||
rate_limit: tuple[int, int] = (2, 3) # Default; (Times, Seconds)
|
||||
_schema_include = endpoint in ["lyric/search"]
|
||||
|
||||
if endpoint == "typeahead/lyrics": # More permissive rate limiting for typeahead
|
||||
rate_limit = (20, 2)
|
||||
(times, seconds) = rate_limit
|
||||
|
||||
app.add_api_route(
|
||||
f"/{endpoint}",
|
||||
handler,
|
||||
methods=["POST"],
|
||||
include_in_schema=_schema_include,
|
||||
dependencies=[Depends(RateLimiter(times=2, seconds=3))],
|
||||
dependencies=[Depends(RateLimiter(times=times, seconds=seconds))] if not endpoint == "typeahead/lyrics" else None
|
||||
)
|
||||
|
||||
|
||||
async def typeahead_handler(self, data: ValidTypeAheadRequest) -> JSONResponse:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user