Skip to content

Commit dae9341

Browse files
committed
wip: add start to embeds server.
1 parent 17ea98f commit dae9341

File tree

4 files changed

+390
-0
lines changed

4 files changed

+390
-0
lines changed

embeds/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

embeds/deno.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tasks": {
3+
"dev": "deno serve -A main.ts"
4+
},
5+
"nodeModulesDir": "auto",
6+
"imports": {
7+
"rivetkit": "npm:rivetkit@^2.1.6"
8+
},
9+
"allowScripts": ["npm:cbor-extract@2.2.0"]
10+
}

embeds/deno.lock

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

embeds/main.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { actor, setup } from "rivetkit";
2+
3+
export const counter = actor({
4+
state: { count: 0 },
5+
actions: {
6+
increment: (c, x: number) => {
7+
c.state.count += x;
8+
c.broadcast("newCount", c.state.count);
9+
return c.state.count;
10+
},
11+
multiply: (c, x: number) => {
12+
c.state.count *= x;
13+
c.broadcast("newCount", c.state.count);
14+
return c.state.count;
15+
}
16+
},
17+
});
18+
19+
export const registry = setup({
20+
use: { counter },
21+
});
22+
23+
// Exposes Rivet API on /api/rivet/ to communicate with actors
24+
export default registry.serve();

0 commit comments

Comments
 (0)