Vishwanath Martur 8b382e8ae0
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.
2025-11-19 13:14:26 +01:00

64 lines
1.7 KiB
Nim

{.push raises: [].}
import
chronicles, json_serialization, json_serialization/std/options, presto/[route, client]
import
../../../waku_store/common,
../../../waku_core/message/digest,
../serdes,
../responses,
./types
export types
logScope:
topics = "waku node rest store_api"
proc decodeBytes*(
t: typedesc[StoreQueryResponseHex],
data: openArray[byte],
contentType: Opt[ContentTypeData],
): RestResult[StoreQueryResponseHex] =
if MediaType.init($contentType) == MIMETYPE_JSON:
let decoded = ?decodeFromJsonBytes(StoreQueryResponseHex, data)
return ok(decoded)
if MediaType.init($contentType) == MIMETYPE_TEXT:
var res: string
if len(data) > 0:
res = newString(len(data))
copyMem(addr res[0], unsafeAddr data[0], len(data))
return ok(
StoreQueryResponseHex(
statusCode: uint32(ErrorCode.BAD_RESPONSE),
statusDesc: res,
messages: newSeq[WakuMessageKeyValueHex](0),
paginationCursor: none(string),
)
)
# If everything goes wrong
return err(cstring("Unsupported contentType " & $contentType))
proc getStoreMessagesV3*(
# URL-encoded reference to the store-node
peerAddr: string = "",
includeData: string = "",
pubsubTopic: string = "",
# URL-encoded comma-separated list of content topics
contentTopics: string = "",
startTime: string = "",
endTime: string = "",
# URL-encoded comma-separated list of message hashes
hashes: string = "",
# Optional cursor fields
cursor: string = "", # base64-encoded hash
ascending: string = "",
pageSize: string = "20", # default value is 20
): RestResponse[StoreQueryResponseHex] {.
rest, endpoint: "/store/v3/messages", meth: HttpMethod.MethodGet
.}