Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ To start using this SDK, you will need the following:

#### Option 1: Using NPM

Install the Ably JavaScript SDK and the Spaces SDK:
Install the Ably Pub/Sub SDK and the Spaces SDK:

```sh
npm install ably @ably/spaces
npm install @ably/pubsub-device @ably/spaces
```

To instantiate the Spaces SDK, create an [Ably client](https://ably.com/docs/getting-started/setup) and pass it into the Spaces constructor:

```ts
import Spaces from '@ably/spaces';
import { Realtime } from 'ably';
import { createClient } from '@ably/pubsub-device';

const client = new Realtime({ key: "<API-key>", clientId: "<client-ID>" });
const client = createClient({ key: "<API-key>", clientId: "<client-ID>" });
const spaces = new Spaces(client);
```
You can use [basic authentication](https://ably.com/docs/auth/basic) i.e. the API Key directly for testing purposes, however it is strongly recommended that you use [token authentication](https://ably.com/docs/auth/token) in production environments.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PresenceMessage, Rest, ErrorInfo } from 'ably';
import { PresenceMessage, Http, ErrorInfo } from '@ably/pubsub-core';

const MOCK_CLIENT_ID = 'MOCK_CLIENT_ID';

Expand Down Expand Up @@ -95,6 +95,6 @@ class MockErrorInfo extends ErrorInfo {}

// maintain the PresenceMessage class so tests can initialise it directly using
// PresenceMessage.fromValues.
MockRealtime.PresenceMessage = Rest.PresenceMessage;
MockRealtime.PresenceMessage = Http.PresenceMessage;

export { MockRealtime as Realtime, MockErrorInfo as ErrorInfo };
4 changes: 2 additions & 2 deletions demo/api/ably-token-request/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as dotenv from 'dotenv';
import * as Ably from 'ably';
import * as Ably from '@ably/pubsub-core';
import { HandlerEvent } from '@netlify/functions';

dotenv.config();
Expand All @@ -21,7 +21,7 @@ Please see README.md for more details on configuring your Ably API Key.`);
}

const clientId = event.queryStringParameters?.['clientId'] || process.env.DEFAULT_CLIENT_ID || 'NO_CLIENT_ID';
const client = new Ably.Rest(process.env.ABLY_API_KEY);
const client = new Ably.Http(process.env.ABLY_API_KEY);
const tokenRequestData = await client.auth.createTokenRequest({ clientId: clientId });

return {
Expand Down
97 changes: 57 additions & 40 deletions demo/api/ably-token-request/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/api/ably-token-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"author": "Netlify",
"license": "MIT",
"dependencies": {
"@ably/pubsub-core": "3.0.0-canary.20260917T1031.521a3374",
"@netlify/functions": "^1.4.0",
"@types/node": "^18.3.0",
"ably": "^2.3.0",
"dotenv": "^16.0.3",
"typescript": "^4.9.5"
}
Expand Down
Loading
Loading