Skip to content

Commit ade9eb2

Browse files
committed
chore(docs): Add descriptions for config parameters
1 parent 1640f65 commit ade9eb2

3 files changed

Lines changed: 83 additions & 2 deletions

File tree

src/adapters/clients.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ import { SerializerNativeImpl } from "./serializers";
1818
import { WebSocketConnectorImpl } from "./ws";
1919

2020
interface LogConfigProps {
21+
/**
22+
* Log level for the client.
23+
*
24+
* - `debug`: Log everything.
25+
* - `info`: Log important information.
26+
* - `warn`: Log warnings.
27+
* - `error`: Log errors.
28+
*
29+
* Defaults to `warn`.
30+
*/
2131
readonly log?: LogType;
2232
}
2333

@@ -52,7 +62,11 @@ export const createOAuthAPIClient = (
5262
};
5363

5464
interface WebSocketCustomImplProps {
55-
/** Custom WebSocket implementation. In Deno, you can use `WebSocket` to avoid potential errors. */
65+
/**
66+
* Custom WebSocket implementation. In Deno, you can use `WebSocket` to avoid potential errors.
67+
*
68+
* Defaults to `window.WebSocket`.
69+
*/
5670
readonly implementation?: unknown;
5771
}
5872

src/adapters/config/http-config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,30 @@ import { mergeHeadersInit } from "./merge-headers-init";
55
const DEFAULT_TIMEOUT_MS = 1000 * 300;
66

77
export interface MastoHttpConfigProps {
8+
/**
9+
* REST API URL for your Mastodon instance.
10+
*/
811
readonly url: string;
12+
13+
/**
14+
* Access token for the REST API.
15+
*
16+
* Please refer to the [quickstart](https://github.com/neet/masto.js?tab=readme-ov-file#quick-start) for how to get an access token.
17+
*/
918
readonly accessToken?: string;
19+
20+
/**
21+
* Timeout in milliseconds.
22+
*
23+
* Defaults to 1000 * 300 = 300 seconds.
24+
*/
1025
readonly timeout?: number;
26+
27+
/**
28+
* Additional options for the `fetch` function.
29+
*
30+
* @see https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
31+
*/
1132
readonly requestInit?: Omit<RequestInit, "body" | "method">;
1233
}
1334

src/adapters/config/web-socket-config.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,55 @@
11
import { type Serializer, type WebSocketConfig } from "../../interfaces";
22

33
export interface WebSocketConfigProps {
4+
/**
5+
* Streaming API URL for your Mastodon instance.
6+
*
7+
* Note that this is often different from the REST API URL.
8+
*
9+
* If you are not sure which URL to use, you can obtain it via the following script:
10+
*
11+
* @example
12+
* ```ts
13+
* import { createRestAPIClient, createStreamingAPIClient } from "masto";
14+
*
15+
* const rest = createRestAPIClient({
16+
* url: "https://example.com",
17+
* });
18+
*
19+
* const instance = await rest.v2.instance.fetch();
20+
*
21+
* const streaming = createStreamingAPIClient({
22+
* streamingApiUrl: instance.configuration.urls.streamingApi,
23+
* })
24+
* ```
25+
*/
426
readonly streamingApiUrl: string;
5-
readonly retry?: boolean | number;
27+
28+
/**
29+
* Access token for the streaming API.
30+
*
31+
* If it is not provided, you won't be able to use private APIs.
32+
*/
633
readonly accessToken?: string;
34+
35+
/**
36+
* Whether to retry the connection when it fails.
37+
*
38+
* - If `true`, it will retry indefinitely.
39+
* - If `false`, it will not retry.
40+
* - If a number, it will retry that many times.
41+
*
42+
* Defaults to `true`.
43+
*/
44+
readonly retry?: boolean | number;
45+
46+
/**
47+
* Whether to use the access token as a query parameter.
48+
*
49+
* This is useful when your instance runs an old version of Mastodon that does not support the `Sec-Websocket-Protocols`
50+
*
51+
* Defaults to `false`.
52+
*/
753
readonly useInsecureAccessToken?: boolean;
854
}
955

0 commit comments

Comments
 (0)