Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
26 changes: 19 additions & 7 deletions docs/how-to/backend/server-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,26 @@ Let's setup everything you need to start communicating with a Fishjam instance.
First of all, view your app in the [**Fishjam developer panel**](https://fishjam.io/app) and copy your **Fishjam ID** and the **Management Token**.
They are required to proceed. Now, we are ready to dive into the code.

`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.

<Tabs groupId="language">
<TabItem value="ts" label="Typescript">

```ts
process.env.FISHJAM_ID = "aaa";
process.env.FISHJAM_MANAGEMENT_TOKEN = "bbb";

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

const fishjamId = process.env.FISHJAM_ID;
const managementToken = process.env.FISHJAM_MANAGEMENT_TOKEN;
const fishjamClient = await FishjamClient.create({
fishjamId: process.env.FISHJAM_ID!,
managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
});

const fishjamClient = new FishjamClient({ fishjamId, managementToken });
// The above is roughly equivalent to:
const fishjamClient = new FishjamClient({ ... });
await fishjamClient.checkCredentials();
```

</TabItem>
Expand All @@ -85,15 +91,21 @@ They are required to proceed. Now, we are ready to dive into the code.
import os
from fishjam import FishjamClient

fishjam_id = os.environ["FISHJAM_ID"]
management_token = os.environ["FISHJAM_MANAGEMENT_TOKEN"]
fishjam_client = FishjamClient.create_and_verify(
fishjam_id=os.environ["FISHJAM_ID"],
management_token=os.environ["FISHJAM_MANAGEMENT_TOKEN"],
)

fishjam_client = FishjamClient(fishjam_id, management_token)
# The above is roughly equivalent to:
fishjam_client = FishjamClient(...)
fishjam_client.check_credentials()
```

</TabItem>
</Tabs>

If you need synchronous construction (for example inside a framework plugin that is not async), use the plain constructor and verify separately. The constructor only checks that the fields are non-empty; it does not contact the backend.
Comment thread
czerwiukk marked this conversation as resolved.
Outdated

### Managing rooms

Create a room to get the `roomId` and be able to start adding peers.
Expand Down
Loading