diff --git a/CHANGES.md b/CHANGES.md index bf70ff60..42ab707a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ### Added * Add `from_extensions()` method to `CollectionSearchExtension` and `CollectionSearchPostExtension` extensions to build the class based on a list of available extensions. +* Add `stac_fastapi_max_search_limit` member to `ApiSettings`, so that it can be used in `types.search.crop()` to clamp `limit` to the desired value. ## [3.0.1] - 2024-08-27 diff --git a/stac_fastapi/types/stac_fastapi/types/config.py b/stac_fastapi/types/stac_fastapi/types/config.py index 75d0bd39..b4f3e2fd 100644 --- a/stac_fastapi/types/stac_fastapi/types/config.py +++ b/stac_fastapi/types/stac_fastapi/types/config.py @@ -23,6 +23,7 @@ class ApiSettings(BaseSettings): stac_fastapi_description: str = "stac-fastapi" stac_fastapi_version: str = "0.1" stac_fastapi_landing_id: str = "stac-fastapi" + stac_fastapi_max_search_limit: int = 10000 app_host: str = "0.0.0.0" app_port: int = 8000 diff --git a/stac_fastapi/types/stac_fastapi/types/search.py b/stac_fastapi/types/stac_fastapi/types/search.py index cfa8baf9..af90ab38 100644 --- a/stac_fastapi/types/stac_fastapi/types/search.py +++ b/stac_fastapi/types/stac_fastapi/types/search.py @@ -13,11 +13,14 @@ from typing_extensions import Annotated from stac_fastapi.types.rfc3339 import DateTimeType, str_to_interval +from stac_fastapi.types.config import ApiSettings +settings = ApiSettings() + def crop(v: PositiveInt) -> PositiveInt: """Crop value to 10,000.""" - limit = 10_000 + limit = settings.stac_fastapi_max_search_limit if v > limit: v = limit return v