Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit e077620

Browse files
NathanFlurryMasterPtato
authored andcommitted
chore(example): update chat example
1 parent 90d2263 commit e077620

File tree

10 files changed

+30
-59
lines changed

10 files changed

+30
-59
lines changed

examples/chat-room/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,13 @@ npm run dev
3232
Open your browser to `http://localhost:3000` to use the web chat interface.
3333

3434
#### CLI Interface
35+
3536
Alternatively, use the CLI interface:
3637

3738
```sh
3839
npm run dev:cli
3940
```
4041

41-
Or connect programmatically:
42-
43-
```sh
44-
tsx src/scripts/connect.ts
45-
```
46-
4742
## Features
4843

4944
- Real-time messaging with automatic persistence
@@ -54,4 +49,4 @@ tsx src/scripts/connect.ts
5449

5550
## License
5651

57-
Apache 2.0
52+
Apache 2.0

examples/chat-room/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
"@vitejs/plugin-react": "^4.2.0",
2020
"concurrently": "^8.2.2",
2121
"prompts": "^2.4.2",
22-
"rivetkit": "workspace:*",
2322
"tsx": "^3.12.7",
2423
"typescript": "^5.5.2",
2524
"vite": "^5.0.0",
26-
"vitest": "^3.1.1"
27-
},
28-
"dependencies": {
25+
"vitest": "^3.1.1",
2926
"@rivetkit/react": "workspace:*",
3027
"react": "^18.2.0",
3128
"react-dom": "^18.2.0"
3229
},
30+
"dependencies": {
31+
"rivetkit": "workspace:*"
32+
},
3333
"stableVersion": "0.8.0"
3434
}

examples/chat-room/src/backend/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import { registry } from "./registry";
33
registry.start({
44
cors: {
55
origin: "http://localhost:5173",
6+
credentials: true,
67
},
78
});

examples/chat-room/src/frontend/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createClient, createRivetKit } from "@rivetkit/react";
22
import { useEffect, useState } from "react";
33
import type { Message, registry } from "../backend/registry";
44

5-
const client = createClient<typeof registry>("http://localhost:8080");
5+
const client = createClient<typeof registry>("http://localhost:6420");
66
const { useActor } = createRivetKit(client);
77

88
export function App() {
@@ -97,4 +97,4 @@ export function App() {
9797
</div>
9898
</div>
9999
);
100-
}
100+
}

examples/chat-room/src/frontend/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ createRoot(root).render(
99
<StrictMode>
1010
<App />
1111
</StrictMode>
12-
);
12+
);

examples/chat-room/src/scripts/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async function main() {
66
const { username, room } = await initPrompt();
77

88
// Create type-aware client
9-
const client = createClient<typeof registry>("http://localhost:8080");
9+
const client = createClient<typeof registry>("http://localhost:6420");
1010

1111
// connect to chat room
1212
const chatRoom = client.chatRoom.getOrCreate([room]).connect();

examples/chat-room/src/scripts/connect.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

examples/chat-room/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ import { defineConfig } from "vite";
44
export default defineConfig({
55
plugins: [react()],
66
root: "src/frontend",
7+
server: {
8+
port: 5173,
9+
},
710
});

packages/cloudflare-workers/src/actor-handler-do.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ import type { ExecutionContext } from "hono";
33
import invariant from "invariant";
44
import type { ActorKey, ActorRouter, Registry, RunConfig } from "rivetkit";
55
import { createActorRouter, createClientWithDriver } from "rivetkit";
6-
import type { ActorDriver, ManagerDriver } from "rivetkit/driver-helpers";
7-
import { serializeEmptyPersistData } from "rivetkit/driver-helpers";
6+
import {
7+
type ManagerDriver,
8+
type ActorDriver,
9+
serializeEmptyPersistData,
10+
} from "rivetkit/driver-helpers";
811
import { promiseWithResolvers } from "rivetkit/utils";
912
import {
1013
CloudflareDurableObjectGlobalState,
@@ -60,8 +63,7 @@ export function createActorDurableObject(
6063
*/
6164
return class ActorHandler
6265
extends DurableObject<Bindings>
63-
implements ActorHandlerInterface
64-
{
66+
implements ActorHandlerInterface {
6567
#initialized?: InitializedData;
6668
#initializedPromise?: ReturnType<typeof promiseWithResolvers<void>>;
6769

pnpm-lock.yaml

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)