Skip to content

Commit 543b2be

Browse files
committed
Add Pub/Sub occupancy example to npm workspace
1 parent b602643 commit 543b2be

13 files changed

+38
-4575
lines changed

examples/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"pub-sub-history/javascript",
3333
"pub-sub-message-encryption/react",
3434
"pub-sub-message-encryption/javascript",
35+
"pub-sub-occupancy/react",
36+
"pub-sub-occupancy/javascript",
3537
"pub-sub-presence/react",
3638
"pub-sub-presence/javascript",
3739
"spaces-avatar-stack/react",
@@ -70,6 +72,8 @@
7072
"pub-sub-history-react": "yarn workspace pub-sub-history-react dev",
7173
"pub-sub-message-encryption-javascript": "yarn workspace pub-sub-message-encryption-javascript dev",
7274
"pub-sub-message-encryption-react": "yarn workspace pub-sub-message-encryption-react dev",
75+
"pub-sub-occupancy-javascript": "yarn workspace pub-sub-occupancy-javascript dev",
76+
"pub-sub-occupancy-react": "yarn workspace pub-sub-occupancy-react dev",
7377
"pub-sub-presence-javascript": "yarn workspace pub-sub-presence-javascript dev",
7478
"pub-sub-presence-react": "yarn workspace pub-sub-presence-react dev",
7579
"spaces-avatar-stack-javascript": "yarn workspace spaces-avatar-stack-javascript dev",
@@ -90,6 +94,7 @@
9094
"nanoid": "^5.0.7",
9195
"react": "^18",
9296
"react-dom": "^18",
97+
"react-icons": "^5.4.0",
9398
"ts-node": "^10.9.2",
9499
"vite": "^5.4.2",
95100
"usehooks-ts": "^3.1.0"

examples/pub-sub-occupancy/javascript/.env.example

-1
This file was deleted.

examples/pub-sub-occupancy/javascript/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ git clone [email protected]:ably/docs.git
1313
2. Change directory:
1414

1515
```sh
16-
cd /examples/pub-sub-occupancy/javascript/
16+
cd /examples/
1717
```
1818

1919
3. Rename the environment file:
@@ -33,7 +33,7 @@ yarn install
3333
6. Run the server:
3434

3535
```sh
36-
yarn run dev
36+
yarn run pub-sub-occupancy-javascript
3737
```
3838

3939
7. Try it out by opening a tab to [http://localhost:5173/](http://localhost:5173/) with your browser to see the result.
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
{
2-
"name": "js-pub-sub-occupancy",
2+
"name": "pub-sub-occupancy-javascript",
33
"version": "1.0.0",
44
"main": "index.js",
55
"license": "MIT",
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc && vite build",
99
"preview": "vite preview"
10-
},
11-
"devDependencies": {
12-
"autoprefixer": "^10.4.20",
13-
"dotenv": "^16.4.5",
14-
"postcss": "^8.4.47",
15-
"tailwindcss": "^3.4.13",
16-
"typescript": "^5.6.3"
17-
},
18-
"dependencies": {
19-
"ably": "^2.3.1",
20-
"nanoid": "^5.0.7",
21-
"vite": "^5.4.12"
2210
}
2311
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { defineConfig } from 'vite'
1+
import { defineConfig } from 'vite';
2+
import dotenv from 'dotenv';
3+
import path from 'path';
4+
5+
dotenv.config({ path: path.resolve(__dirname, '../../.env.local') });
26

37
export default defineConfig({
48
css: {
59
postcss: {
6-
plugins: [
7-
require('tailwindcss'),
8-
require('autoprefixer'),
9-
],
10-
}
11-
}
12-
})
10+
plugins: [require('tailwindcss'), require('autoprefixer')],
11+
},
12+
},
13+
});

examples/pub-sub-occupancy/javascript/yarn.lock

-1,335
This file was deleted.

examples/pub-sub-occupancy/page.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ git clone [email protected]:ably/docs.git
4444
2. Change directory:
4545

4646
```sh
47-
cd /examples/pub-sub-occupancy/react/
47+
cd /examples/
4848
```
4949

5050
3. Rename the environment file:
@@ -53,7 +53,7 @@ cd /examples/pub-sub-occupancy/react/
5353
mv .env.example .env.local
5454
```
5555

56-
4. In `.env.local` update the value of `VITE_PUBLIC_API_KEY` to be your Ably API key.
56+
4. In `.env.local` update the value of `NEXT_PUBLIC_ABLY_KEY` to be your Ably API key.
5757

5858
5. Install dependencies:
5959

@@ -64,7 +64,7 @@ yarn install
6464
6. Run the server:
6565

6666
```sh
67-
yarn run dev
67+
yarn run pub-sub-occupancy-react
6868
```
6969

7070
7. Try it out by opening a tab to [http://localhost:3000/](http://localhost:3000/) with your browser to see the result.
@@ -80,7 +80,7 @@ git clone [email protected]:ably/docs.git
8080
2. Change directory:
8181

8282
```sh
83-
cd /examples/pub-sub-occupancy/javascript/
83+
cd /examples/
8484
```
8585

8686
3. Rename the environment file:
@@ -100,7 +100,7 @@ yarn install
100100
6. Run the server:
101101

102102
```sh
103-
yarn run dev
103+
yarn run pub-sub-occupancy-javascript
104104
```
105105

106106
7. Try it out by opening a tab to [http://localhost:5173/](http://localhost:5173/) with your browser to see the result.

examples/pub-sub-occupancy/react/.env.example

-1
This file was deleted.

examples/pub-sub-occupancy/react/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ git clone [email protected]:ably/docs.git
1313
2. Change directory:
1414

1515
```sh
16-
cd /examples/pub-sub-occupancy/react/
16+
cd /examples/
1717
```
1818

1919
3. Rename the environment file:
@@ -33,7 +33,7 @@ yarn install
3333
6. Run the server:
3434

3535
```sh
36-
yarn run dev
36+
yarn run pub-sub-occupancy-react
3737
```
3838

3939
7. Try it out by opening a tab to [http://localhost:3000/](http://localhost:3000/) with your browser to see the result.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import type { NextConfig } from "next";
2+
import dotenv from 'dotenv';
3+
import path from 'path';
4+
5+
dotenv.config({ path: path.resolve(process.cwd(), '../../.env.local') });
26

37
const nextConfig: NextConfig = {
4-
/* config options here */
8+
reactStrictMode: true,
9+
env: {
10+
NEXT_PUBLIC_ABLY_KEY: process.env.NEXT_PUBLIC_ABLY_KEY,
11+
},
512
};
613

714
export default nextConfig;
+1-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,11 @@
11
{
2-
"name": "react-pub-sub-occupancy",
2+
"name": "pub-sub-occupancy-react",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint"
10-
},
11-
"dependencies": {
12-
"ably": "^2.5.0",
13-
"next": "15.1.3",
14-
"react": "^19.0.0",
15-
"react-dom": "^19.0.0",
16-
"react-icons": "^5.4.0"
17-
},
18-
"devDependencies": {
19-
"@eslint/eslintrc": "^3",
20-
"@types/node": "^20",
21-
"@types/react": "^19",
22-
"@types/react-dom": "^19",
23-
"eslint": "^9",
24-
"eslint-config-next": "15.1.3",
25-
"postcss": "^8",
26-
"tailwindcss": "^3.4.1",
27-
"typescript": "^5"
2810
}
2911
}

0 commit comments

Comments
 (0)