verani 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,9 +28,23 @@ npm install verani @cloudflare/actors
|
|
|
28
28
|
bun add verani @cloudflare/actors
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
**Don't have a Cloudflare Worker project yet?** Create one using [C3 (create-cloudflare)](https://developers.cloudflare.com/pages/get-started/c3/):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm create cloudflare@latest my-verani-app
|
|
35
|
+
cd my-verani-app
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This creates a new Cloudflare Worker project ready for Verani. Choose "Hello World" or "Common" template when prompted.
|
|
39
|
+
|
|
31
40
|
### Server Side (Cloudflare Worker)
|
|
32
41
|
|
|
42
|
+
**Suggested folder structure** (optional, for clarity):
|
|
43
|
+
- `src/actors/chat.actor.ts` - Room definitions
|
|
44
|
+
- `src/index.ts` - Export Durable Object classes
|
|
45
|
+
|
|
33
46
|
```typescript
|
|
47
|
+
// src/actors/chat.actor.ts
|
|
34
48
|
import { defineRoom, createActorHandler } from "verani";
|
|
35
49
|
|
|
36
50
|
// Define your room with lifecycle hooks
|
|
@@ -70,6 +84,15 @@ chatRoom.on("chat.message", (ctx, data) => {
|
|
|
70
84
|
export const ChatRoom = createActorHandler(chatRoom);
|
|
71
85
|
```
|
|
72
86
|
|
|
87
|
+
```typescript
|
|
88
|
+
// src/index.ts
|
|
89
|
+
import { createActorHandler } from "verani";
|
|
90
|
+
import { chatRoom } from "./actors/chat.actor";
|
|
91
|
+
|
|
92
|
+
// Create and export the Durable Object class
|
|
93
|
+
export const ChatRoom = createActorHandler(chatRoom);
|
|
94
|
+
```
|
|
95
|
+
|
|
73
96
|
### Wrangler Configuration
|
|
74
97
|
|
|
75
98
|
**Critical**: Each `defineRoom()` creates a room definition, and `createActorHandler()` converts it into a Durable Object class. This class **must be exported** and **declared in Wrangler configuration**.
|