feat: configurable API rate limit
This commit is contained in:
@@ -17,6 +17,7 @@ class Parameters:
|
||||
timeout: int = 120
|
||||
db_uri: str = "sqlite://db.sqlite"
|
||||
cache_uri: str = "memory://"
|
||||
api_rate_limit: str = "100/minute"
|
||||
|
||||
@classmethod
|
||||
def from_namespace(cls, args: argparse.Namespace) -> Parameters:
|
||||
@@ -128,5 +129,12 @@ def parse_parameters(args: typing.Sequence[str]) -> Parameters:
|
||||
default=default_values.cache_uri,
|
||||
help_txt="cache connection URI",
|
||||
)
|
||||
__add_arg_str(
|
||||
parser,
|
||||
"--api-rate-limit",
|
||||
env_var="API_RATE_LIMIT",
|
||||
default=default_values.api_rate_limit,
|
||||
help_txt="API rate limit (flask-limiter syntax)",
|
||||
)
|
||||
parsed_args = parser.parse_args(args)
|
||||
return Parameters.from_namespace(parsed_args)
|
||||
|
||||
Reference in New Issue
Block a user