Rest store api constraints default page size to 20 and max to 100 (#3602)

Co-authored-by: Vishwanath Martur <64204611+vishwamartur@users.noreply.github.com>
This commit is contained in:
Ivan FB 2025-12-03 11:55:34 +01:00 committed by GitHub
parent 54f4ad8fa2
commit 8c30a8e1bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 2 deletions

View File

@ -38,6 +38,9 @@ A particular OpenAPI spec can be easily imported into [Postman](https://www.post
curl http://localhost:8645/debug/v1/info -s | jq curl http://localhost:8645/debug/v1/info -s | jq
``` ```
### Store API
The `page_size` flag in the Store API has a default value of 20 and a max value of 100.
### Node configuration ### Node configuration
Find details [here](https://github.com/waku-org/nwaku/tree/master/docs/operators/how-to/configure-rest-api.md) Find details [here](https://github.com/waku-org/nwaku/tree/master/docs/operators/how-to/configure-rest-api.md)

View File

@ -1,4 +1,3 @@
# Configure a REST API node # Configure a REST API node
A subset of the node configuration can be used to modify the behaviour of the HTTP REST API. A subset of the node configuration can be used to modify the behaviour of the HTTP REST API.
@ -21,3 +20,5 @@ Example:
```shell ```shell
wakunode2 --rest=true wakunode2 --rest=true
``` ```
The `page_size` flag in the Store API has a default value of 20 and a max value of 100.

View File

@ -57,7 +57,7 @@ proc getStoreMessagesV3*(
# Optional cursor fields # Optional cursor fields
cursor: string = "", # base64-encoded hash cursor: string = "", # base64-encoded hash
ascending: string = "", ascending: string = "",
pageSize: string = "", pageSize: string = "20", # default value is 20
): RestResponse[StoreQueryResponseHex] {. ): RestResponse[StoreQueryResponseHex] {.
rest, endpoint: "/store/v3/messages", meth: HttpMethod.MethodGet rest, endpoint: "/store/v3/messages", meth: HttpMethod.MethodGet
.} .}

View File

@ -129,6 +129,14 @@ proc createStoreQuery(
except CatchableError: except CatchableError:
return err("page size parsing error: " & getCurrentExceptionMsg()) return err("page size parsing error: " & getCurrentExceptionMsg())
# Enforce default value of page_size to 20
if parsedPagedSize.isNone():
parsedPagedSize = some(20.uint64)
# Enforce max value of page_size to 100
if parsedPagedSize.get() > 100:
parsedPagedSize = some(100.uint64)
return ok( return ok(
StoreQueryRequest( StoreQueryRequest(
includeData: parsedIncludeData, includeData: parsedIncludeData,