Skip to content

Commit 709740a

Browse files
authored
FCE-2044 sdk clients should fail fast when misconfigured (#259)
## Description Adjusts the docs to the new sdk changes.
1 parent affba66 commit 709740a

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

docs/how-to/backend/server-setup.mdx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,29 @@ Let's setup everything you need to start communicating with a Fishjam instance.
6161
First of all, view your app in the [**Fishjam developer panel**](https://fishjam.io/app) and copy your **Fishjam ID** and the **Management Token**.
6262
They are required to proceed. Now, we are ready to dive into the code.
6363

64+
`FishjamClient.create` constructs the client and pings the Fishjam backend with the supplied credentials, so a bad `fishjamId` or `managementToken` fails at startup instead of on the first room operation.
65+
6466
<Tabs groupId="language">
6567
<TabItem value="ts" label="Typescript">
66-
68+
6769
```ts
6870
process.env.FISHJAM_ID = "aaa";
6971
process.env.FISHJAM_MANAGEMENT_TOKEN = "bbb";
7072

7173
// ---cut---
7274
import { FishjamClient } from '@fishjam-cloud/js-server-sdk';
7375

74-
const fishjamId = process.env.FISHJAM_ID;
75-
const managementToken = process.env.FISHJAM_MANAGEMENT_TOKEN;
76+
let fishjamClient = await FishjamClient.create({
77+
fishjamId: process.env.FISHJAM_ID!,
78+
managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
79+
});
7680

77-
const fishjamClient = new FishjamClient({ fishjamId, managementToken });
81+
// The above is roughly equivalent to:
82+
fishjamClient = new FishjamClient({
83+
fishjamId: process.env.FISHJAM_ID!,
84+
managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
85+
});
86+
await fishjamClient.checkCredentials();
7887
```
7988

8089
</TabItem>
@@ -85,10 +94,14 @@ They are required to proceed. Now, we are ready to dive into the code.
8594
import os
8695
from fishjam import FishjamClient
8796

88-
fishjam_id = os.environ["FISHJAM_ID"]
89-
management_token = os.environ["FISHJAM_MANAGEMENT_TOKEN"]
97+
fishjam_client = FishjamClient.create_and_verify(
98+
fishjam_id=os.environ["FISHJAM_ID"],
99+
management_token=os.environ["FISHJAM_MANAGEMENT_TOKEN"],
100+
)
90101

91-
fishjam_client = FishjamClient(fishjam_id, management_token)
102+
# The above is roughly equivalent to:
103+
fishjam_client = FishjamClient(...)
104+
fishjam_client.check_credentials()
92105
```
93106

94107
</TabItem>

0 commit comments

Comments
 (0)