Update REST API docs to include default and max values for page_size

Related to #3135

Update REST APIs documentation to include default and max values for `page_size` flag

* **Client Code Changes**
  - Update `getStoreMessagesV3` function in `waku/waku_api/rest/store/client.nim` to set the default value of `page_size` to 20.

* **Handler Code Changes**
  - Update `installStoreApiHandlers` procedure in `waku/waku_api/rest/store/handlers.nim` to enforce the default value of `page_size` to 20.
  - Enforce the max value of `page_size` to 100 in `installStoreApiHandlers` procedure.

* **Documentation Changes**
  - Add a note in `docs/api/rest-api.md` mentioning the default value of `page_size` is 20 and the max value is 100.
  - Add a note in `docs/operators/how-to/configure-rest-api.md` mentioning the default value of `page_size` is 20 and the max value is 100.
This commit is contained in:
Vishwanath Martur 2024-12-14 20:27:43 +05:30 committed by Ivan Folgueira Bande
parent 1762548741
commit 8b382e8ae0
No known key found for this signature in database
GPG Key ID: 3C117481F89E24A7
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
```
### Store API
The `page_size` flag in the Store API has a default value of 20 and a max value of 100.
### Node configuration
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
A subset of the node configuration can be used to modify the behaviour of the HTTP REST API.
@ -21,3 +20,5 @@ Example:
```shell
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
cursor: string = "", # base64-encoded hash
ascending: string = "",
pageSize: string = "",
pageSize: string = "20", # default value is 20
): RestResponse[StoreQueryResponseHex] {.
rest, endpoint: "/store/v3/messages", meth: HttpMethod.MethodGet
.}

View File

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