Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/api/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion docs/operators/how-to/configure-rest-api.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
2 changes: 1 addition & 1 deletion waku/waku_api/rest/store/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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[StoreQueryResponse] {.
rest, endpoint: "/store/v3/messages", meth: HttpMethod.MethodGet
.}
8 changes: 8 additions & 0 deletions waku/waku_api/rest/store/handlers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,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,
Expand Down
Loading