Skip to content

Commit b913a98

Browse files
authored
[EDU-1816] - Add NPM Workspaces to examples
2 parents 42e446d + 97ad0c1 commit b913a98

File tree

221 files changed

+1868
-67530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+1868
-67530
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
VITE_PUBLIC_ABLY_KEY=
12
NEXT_PUBLIC_ABLY_KEY=

examples/auth-generate-jwt/javascript/README.md

+5-5
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/auth-generate-jwt/javascript/
16+
cd /examples/
1717
```
1818

1919
3. Install dependencies:
@@ -25,13 +25,13 @@ yarn install
2525
4. Run the frontend client:
2626

2727
```sh
28-
yarn run dev
28+
yarn run auth-generate-jwt-javascript
2929
```
3030

3131
5. In a new tab, change directory:
3232

3333
```sh
34-
cd /examples/auth-generate-jwt/server/
34+
cd /examples/
3535
```
3636

3737
6. Rename the environment file:
@@ -40,7 +40,7 @@ cd /examples/auth-generate-jwt/server/
4040
mv .env.example .env.local
4141
```
4242

43-
7. In `.env.local` update the value of `ABLY_API_KEY` to be your Ably API key.
43+
7. In `.env.local` update the value of `VITE_PUBLIC_ABLY_KEY` to be your Ably API key.
4444

4545
8. Install dependencies:
4646

@@ -51,7 +51,7 @@ yarn install
5151
9. Run the backend server:
5252

5353
```sh
54-
yarn run dev
54+
yarn run auth-generate-jwt-server
5555
```
5656

5757
10. 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": "auth-request-token",
2+
"name": "auth-generate-jwt-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
}

examples/auth-generate-jwt/page.md

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

4545
```sh
46-
cd /examples/auth-generate-jwt/react/
46+
cd /examples/
4747
```
4848

4949
3. Install dependencies:
@@ -55,13 +55,13 @@ yarn install
5555
4. Run the frontend client:
5656

5757
```sh
58-
yarn run dev
58+
yarn run auth-generate-jwt-react
5959
```
6060

6161
5. In a new tab, change directory:
6262

6363
```sh
64-
cd /examples/auth-generate-jwt/server/
64+
cd /examples/
6565
```
6666

6767
6. Rename the environment file:
@@ -70,7 +70,7 @@ cd /examples/auth-generate-jwt/server/
7070
mv .env.example .env.local
7171
```
7272

73-
7. In `.env.local` update the value of `NEXT_PUBLIC_ABLY_KEY` to be your Ably API key.
73+
7. In `.env.local` update the value of `VITE_PUBLIC_ABLY_KEY` to be your Ably API key.
7474

7575
8. Install dependencies:
7676

@@ -81,7 +81,7 @@ yarn install
8181
9. Run the backend server:
8282

8383
```sh
84-
yarn run dev
84+
yarn run auth-generate-jwt-server
8585
```
8686

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

9999
```sh
100-
cd /examples/auth-generate-jwt/javascript/
100+
cd /examples/
101101
```
102102

103103
3. Install dependencies:
@@ -109,13 +109,13 @@ yarn install
109109
4. Run the frontend client:
110110

111111
```sh
112-
yarn run dev
112+
yarn run auth-generate-jwt-javascript
113113
```
114114

115115
5. In a new tab, change directory:
116116

117117
```sh
118-
cd /examples/auth-generate-jwt/server/
118+
cd /examples/
119119
```
120120

121121
6. Rename the environment file:
@@ -135,7 +135,7 @@ yarn install
135135
9. Run the backend server:
136136

137137
```sh
138-
yarn run dev
138+
yarn run auth-generate-jwt-server
139139
```
140140

141141
10. Try it out by opening a tab to [http://localhost:5173/](http://localhost:5173/) with your browser to see the result.
@@ -144,7 +144,7 @@ yarn run dev
144144

145145
// React
146146

147-
In CodeSandbox, rename the `.env.example` file to `.env.local` and update the value of your `NEXT_PUBLIC_ABLY_KEY` variable to use your Ably API key.
147+
In CodeSandbox, rename the `.env.example` file to `.env.local` and update the value of your `VITE_PUBLIC_ABLY_KEY` variable to use your Ably API key.
148148

149149
// Javascript
150150

examples/auth-generate-jwt/react/README.md

+5-5
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/auth-generate-jwt/react/
16+
cd /examples/
1717
```
1818

1919
3. Install dependencies:
@@ -25,13 +25,13 @@ yarn install
2525
4. Run the frontend client:
2626

2727
```sh
28-
yarn run dev
28+
yarn run auth-generate-jwt-react
2929
```
3030

3131
5. In a new tab, change directory:
3232

3333
```sh
34-
cd /examples/auth-generate-jwt/server/
34+
cd /examples/
3535
```
3636

3737
6. Rename the environment file:
@@ -40,7 +40,7 @@ cd /examples/auth-generate-jwt/server/
4040
mv .env.example .env.local
4141
```
4242

43-
7. In `.env.local` update the value of `ABLY_API_KEY` to be your Ably API key.
43+
7. In `.env.local` update the value of `VITE_PUBLIC_ABLY_KEY` to be your Ably API key.
4444

4545
8. Install dependencies:
4646

@@ -51,7 +51,7 @@ yarn install
5151
9. Run the backend server:
5252

5353
```sh
54-
yarn run dev
54+
yarn run auth-generate-jwt-server
5555
```
5656

5757
10. Try it out by opening a tab to [http://localhost:3000/](http://localhost:3000/) with your browser to see the result.
+1-18
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
{
2-
"name": "react",
2+
"name": "auth-generate-jwt-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.4.0",
13-
"nanoid": "^5.0.9",
14-
"next": "14.2.21",
15-
"react": "^18",
16-
"react-dom": "^18"
17-
},
18-
"devDependencies": {
19-
"@types/node": "^20",
20-
"@types/react": "^18",
21-
"@types/react-dom": "^18",
22-
"eslint": "^8",
23-
"eslint-config-next": "15.0.3",
24-
"postcss": "^8",
25-
"tailwindcss": "^3.4.1",
26-
"typescript": "^5"
2710
}
2811
}

examples/auth-generate-jwt/server/.env.example

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
{
2-
"name": "server",
2+
"name": "auth-generate-jwt-server",
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
77
"dev": "ts-node src/server.ts",
88
"build": "tsc",
99
"start": "node dist/server.js"
10-
},
11-
"keywords": [],
12-
"author": "",
13-
"license": "ISC",
14-
"dependencies": {
15-
"@types/express": "^5.0.0",
16-
"@types/node": "^22.10.1",
17-
"ably": "^2.5.0",
18-
"cors": "^2.8.5",
19-
"dotenv": "^16.4.5",
20-
"express": "^4.21.1",
21-
"ts-node": "^10.9.2",
22-
"typescript": "^5.7.2"
2310
}
2411
}

examples/auth-generate-jwt/server/src/server.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import express from 'express';
2+
import path from 'path';
23
import dotenv from 'dotenv';
34
import cors from 'cors';
45
import crypto from 'crypto';
56

6-
dotenv.config({ path: '.env.local' });
7+
dotenv.config({ path: path.resolve(__dirname, '../../../.env.local') });
78

89
const app = express();
910
const port = 3001;
@@ -22,11 +23,11 @@ function base64urlEncode(str: string) {
2223
app.get('/generate-jwt', async (_req, res) => {
2324
console.log('1 - /generate-jwt endpoint called');
2425

25-
const ablyApiKey = process.env.ABLY_API_KEY || '';
26+
const ablyApiKey = process.env.VITE_PUBLIC_ABLY_KEY || '';
2627
const [apiKeyName, apiKeySecret] = ablyApiKey.split(':');
2728
try {
2829
if (ablyApiKey === '') {
29-
throw new Error('ABLY_API_KEY is not set');
30+
throw new Error('VITE_PUBLIC_ABLY_KEY is not set');
3031
}
3132

3233
const header = {

examples/auth-generate-jwt/server/vite.config.ts

-7
This file was deleted.

0 commit comments

Comments
 (0)