Skip to content
Open
Changes from all 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
55 changes: 48 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,59 @@ 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.

The verifying factory 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 fishjamClient = await FishjamClient.create({
fishjamId: process.env.FISHJAM_ID!,
managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
});
```

</TabItem>

<TabItem value="python" label="Python">

```python
import os
from fishjam import FishjamClient

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

</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 on lines +99 to +100
<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 = new FishjamClient({
fishjamId: process.env.FISHJAM_ID!,
managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!,
});

const fishjamClient = new FishjamClient({ fishjamId, managementToken });
await fishjamClient.checkCredentials();
```

</TabItem>
Expand All @@ -85,10 +124,12 @@ 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(
fishjam_id=os.environ["FISHJAM_ID"],
management_token=os.environ["FISHJAM_MANAGEMENT_TOKEN"],
)

fishjam_client = FishjamClient(fishjam_id, management_token)
fishjam_client.check_credentials()
```

</TabItem>
Expand Down
Loading