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

Commit 0420874

Browse files
NathanFlurryjog1t
authored andcommitted
chore: implement Registry.run
1 parent a08ff6e commit 0420874

Some content is hidden

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

76 files changed

+1846
-799
lines changed

examples/elysia/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "example-elysia",
3+
"version": "0.9.0-rc.1",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "bun --watch src/server.ts",
8+
"check-types": "tsc --noEmit"
9+
},
10+
"devDependencies": {
11+
"@types/node": "^22.13.9",
12+
"rivetkit": "workspace:*",
13+
"typescript": "^5.5.2"
14+
},
15+
"dependencies": {
16+
"@rivetkit/memory": "workspace:0.9.0-rc.1",
17+
"@rivetkit/react": "workspace:0.9.0-rc.1",
18+
"elysia": "^1.3.5",
19+
"react": "^18.2.0",
20+
"react-dom": "^18.2.0"
21+
},
22+
"example": {
23+
"platforms": ["*"]
24+
},
25+
"stableVersion": "0.8.0"
26+
}

examples/elysia/src/registry.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { worker, setup } from "rivetkit";
2+
3+
export const counter = worker({
4+
onAuth: () => {
5+
// Configure auth here
6+
},
7+
state: { count: 0 },
8+
actions: {
9+
increment: (c, x: number) => {
10+
c.state.count += x;
11+
return c.state.count;
12+
},
13+
},
14+
});
15+
16+
export const registry = setup({
17+
workers: { counter },
18+
});
19+
20+
export type Registry = typeof registry;

examples/elysia/src/server.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { registry } from "./registry";
2+
import { Elysia } from "elysia";
3+
import { createMemoryDriver } from "@rivetkit/memory";
4+
5+
// Start RivetKit
6+
const { client, handler } = registry.run({
7+
driver: createMemoryDriver(),
8+
});
9+
10+
// Setup router
11+
const app = new Elysia()
12+
// Expose RivetKit to the frontend (optional)
13+
.mount("/registry", handler)
14+
// Example HTTP endpoint
15+
.post("/increment/:name", async ({ params }) => {
16+
const name = params.name;
17+
18+
const counter = client.counter.getOrCreate(name);
19+
const newCount = await counter.increment(1);
20+
21+
return `New Count: ${newCount}`;
22+
})
23+
.listen(3001);
24+
25+
console.log("Listening at http://localhost:3001");

examples/elysia/tsconfig.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
5+
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
6+
"target": "esnext",
7+
/* Specify a set of bundled library declaration files that describe the target runtime environment. */
8+
"lib": ["esnext"],
9+
/* Specify what JSX code is generated. */
10+
"jsx": "react-jsx",
11+
12+
/* Specify what module code is generated. */
13+
"module": "esnext",
14+
/* Specify how TypeScript looks up a file from a given module specifier. */
15+
"moduleResolution": "bundler",
16+
/* Specify type package names to be included without being referenced in a source file. */
17+
"types": ["node"],
18+
/* Enable importing .json files */
19+
"resolveJsonModule": true,
20+
21+
/* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
22+
"allowJs": true,
23+
/* Enable error reporting in type-checked JavaScript files. */
24+
"checkJs": false,
25+
26+
/* Disable emitting files from a compilation. */
27+
"noEmit": true,
28+
29+
/* Ensure that each file can be safely transpiled without relying on other imports. */
30+
"isolatedModules": true,
31+
/* Allow 'import x from y' when a module doesn't have a default export. */
32+
"allowSyntheticDefaultImports": true,
33+
/* Ensure that casing is correct in imports. */
34+
"forceConsistentCasingInFileNames": true,
35+
36+
/* Enable all strict type-checking options. */
37+
"strict": true,
38+
39+
/* Skip type checking all .d.ts files. */
40+
"skipLibCheck": true
41+
},
42+
"include": ["src/**/*"]
43+
}

examples/express/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "example-express",
3+
"version": "0.9.0-rc.1",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "tsx --watch src/server.ts",
8+
"check-types": "tsc --noEmit"
9+
},
10+
"devDependencies": {
11+
"@types/express": "^4.17.21",
12+
"@types/node": "^22.13.9",
13+
"rivetkit": "workspace:*",
14+
"tsx": "^3.12.7",
15+
"typescript": "^5.5.2"
16+
},
17+
"dependencies": {
18+
"@rivetkit/memory": "workspace:0.9.0-rc.1",
19+
"@rivetkit/react": "workspace:0.9.0-rc.1",
20+
"express": "^5.1.0",
21+
"react": "^18.2.0",
22+
"react-dom": "^18.2.0"
23+
},
24+
"example": {
25+
"platforms": ["*"]
26+
},
27+
"stableVersion": "0.8.0"
28+
}

examples/express/src/registry.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { worker, setup } from "rivetkit";
2+
3+
export const counter = worker({
4+
onAuth: () => {
5+
// Configure auth here
6+
},
7+
state: { count: 0 },
8+
actions: {
9+
increment: (c, x: number) => {
10+
c.state.count += x;
11+
return c.state.count;
12+
},
13+
},
14+
});
15+
16+
export const registry = setup({
17+
workers: { counter },
18+
});
19+
20+
export type Registry = typeof registry;

examples/express/src/server.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { registry } from "./registry";
2+
import express from "express";
3+
import { createMemoryDriver } from "@rivetkit/memory";
4+
5+
// Start RivetKit
6+
const { client, handler } = registry.run({
7+
driver: createMemoryDriver(),
8+
});
9+
10+
// Setup router
11+
const app = express();
12+
13+
// Expose RivetKit to the frontend (optional)
14+
app.use("/registry", handler);
15+
16+
// Example HTTP endpoint
17+
app.post("/increment/:name", async (req, res) => {
18+
const name = req.params.name;
19+
20+
const counter = client.counter.getOrCreate(name);
21+
const newCount = await counter.increment(1);
22+
23+
res.send(`New Count: ${newCount}`);
24+
});
25+
26+
app.listen(3001, () => {
27+
console.log("Listening at http://localhost:3001");
28+
});

examples/express/tsconfig.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
5+
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
6+
"target": "esnext",
7+
/* Specify a set of bundled library declaration files that describe the target runtime environment. */
8+
"lib": ["esnext"],
9+
/* Specify what JSX code is generated. */
10+
"jsx": "react-jsx",
11+
12+
/* Specify what module code is generated. */
13+
"module": "esnext",
14+
/* Specify how TypeScript looks up a file from a given module specifier. */
15+
"moduleResolution": "bundler",
16+
/* Specify type package names to be included without being referenced in a source file. */
17+
"types": ["node"],
18+
/* Enable importing .json files */
19+
"resolveJsonModule": true,
20+
21+
/* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
22+
"allowJs": true,
23+
/* Enable error reporting in type-checked JavaScript files. */
24+
"checkJs": false,
25+
26+
/* Disable emitting files from a compilation. */
27+
"noEmit": true,
28+
29+
/* Ensure that each file can be safely transpiled without relying on other imports. */
30+
"isolatedModules": true,
31+
/* Allow 'import x from y' when a module doesn't have a default export. */
32+
"allowSyntheticDefaultImports": true,
33+
/* Ensure that casing is correct in imports. */
34+
"forceConsistentCasingInFileNames": true,
35+
36+
/* Enable all strict type-checking options. */
37+
"strict": true,
38+
39+
/* Skip type checking all .d.ts files. */
40+
"skipLibCheck": true
41+
},
42+
"include": ["src/**/*"]
43+
}

examples/hono-react/package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "example-hono-react",
3+
"version": "0.9.0-rc.1",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "concurrently \"npm run dev:backend\" \"npm run dev:frontend\"",
8+
"dev:backend": "tsx --watch src/backend/server.ts",
9+
"dev:frontend": "vite",
10+
"build": "vite build",
11+
"check-types": "tsc --noEmit",
12+
"test": "vitest run"
13+
},
14+
"devDependencies": {
15+
"@types/node": "^22.13.9",
16+
"@types/react": "^18.2.0",
17+
"@types/react-dom": "^18.2.0",
18+
"@vitejs/plugin-react": "^4.2.0",
19+
"concurrently": "^8.2.2",
20+
"rivetkit": "workspace:*",
21+
"tsx": "^3.12.7",
22+
"typescript": "^5.5.2",
23+
"vite": "^5.0.0",
24+
"vitest": "^3.1.1"
25+
},
26+
"dependencies": {
27+
"@hono/node-server": "^1.14.4",
28+
"@rivetkit/memory": "workspace:0.9.0-rc.1",
29+
"@rivetkit/react": "workspace:0.9.0-rc.1",
30+
"hono": "^4.7.0",
31+
"react": "^18.2.0",
32+
"react-dom": "^18.2.0"
33+
},
34+
"example": {
35+
"platforms": [
36+
"*"
37+
]
38+
},
39+
"stableVersion": "0.8.0"
40+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { worker, setup } from "rivetkit";
2+
3+
export const counter = worker({
4+
onAuth: () => {
5+
// Configure auth here
6+
},
7+
state: { count: 0 },
8+
actions: {
9+
increment: (c, x: number) => {
10+
c.state.count += x;
11+
return c.state.count;
12+
},
13+
},
14+
});
15+
16+
export const registry = setup({
17+
workers: { counter },
18+
});
19+
20+
export type Registry = typeof registry;

0 commit comments

Comments
 (0)