diff --git a/dts/lib.fleek.d.ts b/dts/lib.fleek.d.ts index 6cf781f..897dcf2 100644 --- a/dts/lib.fleek.d.ts +++ b/dts/lib.fleek.d.ts @@ -40,7 +40,51 @@ declare namespace Fleek { * Read a given block index from the blockstore * @param {number} idx - Index of block to read * @returns {Promise} + * @category Fleek Node API */ readBlock(idx: number): Promise; } + + /** HTTP request methods. + * @category Fleek Node API + */ + type HttpRequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD"; + + /** HTTP request object. + * @property {HttpMethod} method - HTTP Request method. + * @property {string} path - Request path. If empty, defaults to `/`. + * @property {Object.} [headers] - List of headers. All entries attempt to be pre-parsed as json/javascript values, otherwise provided as strings. + * @property {Object.} [query] - List of query parameters. All entries attempt to be pre-parsed as json/javascript values, otherwise provided as strings. + * @property {any} [body] - Request body. Attempts to be pre-parsed as a json/javascript value, otherwise provided as a string. + * @category Fleek Node API + */ + type HttpRequest = { + method: HttpRequestMethod; + path: String; + headers?: Map; + query?: Map; + body?: any; + }; + + /** Valid header formats for an HTTP response. + * @category Fleek Node API + */ + type HttpResponseHeaders = + | Map + | Map + | [string, string][] + | [string, string[]][]; + + /** HTTP Response object. When returned from a function that's requested over http, it will be used to + * modify the http response. Otherwise, for non-http requests, the raw json object will be sent. + * @property {Number} code - Status code to use. Must be an unsigned integer that fits inside a u16. + * @property {Headers} headers - Array or map of header key values + * @property {any} body - Body to send to client + * @category Fleek Node API + */ + type HttpResponse = { + code: number; + headers: HttpResponseHeaders; + body: any; + }; }