Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/counter/scripts/connect.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/// <reference types="node" />
import { createClient } from "@rivetkit/worker/client";
import type { Registry } from "../workers/registry";
import type { Registry } from "../src/workers/registry";

async function main() {
const client = createClient<Registry>(process.env.ENDPOINT ?? "http://localhost:6420");
const client = createClient<Registry>(
process.env.ENDPOINT ?? "http://127.0.0.1:8080",
);

const counter = client.counter.connect()
const counter = (await client.counter.getOrCreate()).connect();

counter.on("newCount", (count: number) => console.log("Event:", count));

Expand Down
1 change: 1 addition & 0 deletions examples/drizzle/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DB_FILE_NAME=file:local.db
33 changes: 33 additions & 0 deletions examples/drizzle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Hono Integration for RivetKit

Example project demonstrating Hono web framework integration with [RivetKit](https://rivetkit.org).
Comment on lines +1 to +3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README title and description in the drizzle example incorrectly identifies this as a "Hono Integration" example when it's actually demonstrating SQLite/Drizzle database integration with RivetKit. The title and description should be updated to accurately reflect the content of this example, which appears to be focused on database integration rather than the Hono web framework.

Suggested change
# Hono Integration for RivetKit
Example project demonstrating Hono web framework integration with [RivetKit](https://rivetkit.org).
# Drizzle SQLite Integration for RivetKit
Example project demonstrating SQLite database integration with [RivetKit](https://rivetkit.org) using Drizzle ORM.

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.


[Learn More →](https://github.com/rivet-gg/rivetkit)

[Discord](https://rivet.gg/discord) — [Documentation](https://rivetkit.org) — [Issues](https://github.com/rivet-gg/rivetkit/issues)

## Getting Started

### Prerequisites

- Node.js

### Installation

```sh
git clone https://github.com/rivet-gg/rivetkit
cd rivetkit/examples/hono
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README in the drizzle example directory contains an incorrect installation path. It instructs users to cd rivetkit/examples/hono when it should be cd rivetkit/examples/drizzle since this is the drizzle example directory.

Suggested change
cd rivetkit/examples/hono
cd rivetkit/examples/drizzle

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

npm install
```

### Development

```sh
npm run dev
```

Open your browser to http://localhost:3000 to see the Hono server with RivetKit integration.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README in the drizzle example references a Hono server and instructs users to open http://localhost:3000, but this appears to be copied from a different example. The drizzle/SQLite example likely doesn't have a web interface or uses a different port. Consider updating the README with instructions specific to this database example.

Suggested change
Open your browser to http://localhost:3000 to see the Hono server with RivetKit integration.
After running the example, you can interact with the SQLite database through the provided scripts or commands. Check the console output for any specific instructions.

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.


## License

Apache 2.0
6 changes: 6 additions & 0 deletions examples/drizzle/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from "@rivetkit/db/drizzle";

export default defineConfig({
out: "./drizzle",
schema: "./src/db/schema.ts",
});
8 changes: 8 additions & 0 deletions examples/drizzle/drizzle/0000_wonderful_iron_patriot.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE `users_table` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`name` text NOT NULL,
`age` integer NOT NULL,
`email` text NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `users_table_email_unique` ON `users_table` (`email`);
64 changes: 64 additions & 0 deletions examples/drizzle/drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"version": "6",
"dialect": "sqlite",
"id": "22f3d49c-97d5-46ca-b0f1-99950c3efec7",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"users_table": {
"name": "users_table",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"age": {
"name": "age",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"users_table_email_unique": {
"name": "users_table_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
20 changes: 20 additions & 0 deletions examples/drizzle/drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "7",
"dialect": "sqlite",
"entries": [
{
"idx": 0,
"version": "6",
"when": 1750711614205,
"tag": "0000_wonderful_iron_patriot",
"breakpoints": true
},
{
"idx": 1,
"version": "6",
"when": 1750716663518,
"tag": "0001_rich_susan_delgado",
"breakpoints": true
}
]
}
10 changes: 10 additions & 0 deletions examples/drizzle/drizzle/migrations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import journal from './meta/_journal.json';
import m0000 from './0000_wonderful_iron_patriot.sql';

export default {
journal,
migrations: {
m0000,
}
}

10 changes: 10 additions & 0 deletions examples/drizzle/hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export async function load(url, context, nextLoad) {
if(url.endsWith('.sql')) {
return {
shortCircuit: true,
format: 'module',
source: `export default 'SQL file loaded from ${url}';`
}
}
return nextLoad(url, context)
}
27 changes: 27 additions & 0 deletions examples/drizzle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "example-sqlite",
"version": "0.9.0-rc.1",
"private": true,
"type": "module",
"scripts": {
"dev": "tsx --watch src/server.ts",
"check-types": "tsc --noEmit"
},
"devDependencies": {
"@types/node": "^22.13.9",
"rivetkit": "workspace:*",
"tsx": "^3.12.7",
"typescript": "^5.5.2"
},
"dependencies": {
"@rivetkit/db": "workspace:0.9.0-rc.1",
"drizzle-kit": "^0.31.2",
"drizzle-orm": "^0.44.2"
},
"example": {
"platforms": [
"*"
]
},
"stableVersion": "0.8.0"
}
15 changes: 15 additions & 0 deletions examples/drizzle/register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {register} from "node:module";
import { pathToFileURL } from 'node:url';


register("./hooks.js", pathToFileURL(__filename))


// registerHooks({
// resolve(specifier, context, nextResolve) {
// console.log({specifier, context});
// },
// load(url, context, nextLoad) {
// console.log({url, context});
// },
// });
9 changes: 9 additions & 0 deletions examples/drizzle/src/db/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// import { int, sqliteTable, text } from "@rivetkit/db/drizzle";

// export const usersTable = sqliteTable("users_table", {
// id: int().primaryKey({ autoIncrement: true }),
// name: text().notNull(),
// age: int().notNull(),
// email: text().notNull().unique(),
// email2: text().notNull().unique(),
// });
27 changes: 27 additions & 0 deletions examples/drizzle/src/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// import { worker, setup } from "rivetkit";
// import { db } from "@rivetkit/db/drizzle";
// import * as schema from "./db/schema";
// import migrations from "../drizzle/migrations";

// export const counter = worker({
// db: db({ schema, migrations }),
// state: {
// count: 0,
// },
// onAuth: () => {
// // Configure auth here
// },
// actions: {
// increment: (c, x: number) => {
// // createState or state fix fix fix
// c.db.c.state.count += x;
// return c.state.count;
// },
// },
// });

// export const registry = setup({
// workers: { counter },
// });

// export type Registry = typeof registry;
7 changes: 7 additions & 0 deletions examples/drizzle/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// import { registry } from "./registry";
// import { createMemoryDriver } from "@rivetkit/memory";
// import { serve } from "@rivetkit/nodejs";

// serve(registry, {
// driver: createMemoryDriver(),
// });
44 changes: 44 additions & 0 deletions examples/drizzle/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */

/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "esnext",
/* Specify a set of bundled library declaration files that describe the target runtime environment. */
"lib": ["esnext"],
/* Specify what JSX code is generated. */
"jsx": "react-jsx",
"allowArbitraryExtensions": true,

/* Specify what module code is generated. */
"module": "esnext",
/* Specify how TypeScript looks up a file from a given module specifier. */
"moduleResolution": "bundler",
/* Specify type package names to be included without being referenced in a source file. */
"types": ["node"],
/* Enable importing .json files */
"resolveJsonModule": true,

/* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
"allowJs": true,
/* Enable error reporting in type-checked JavaScript files. */
"checkJs": false,

/* Disable emitting files from a compilation. */
"noEmit": true,

/* Ensure that each file can be safely transpiled without relying on other imports. */
"isolatedModules": true,
/* Allow 'import x from y' when a module doesn't have a default export. */
"allowSyntheticDefaultImports": true,
/* Ensure that casing is correct in imports. */
"forceConsistentCasingInFileNames": true,

/* Enable all strict type-checking options. */
"strict": true,

/* Skip type checking all .d.ts files. */
"skipLibCheck": true
},
"include": ["src/**/*"]
}
68 changes: 68 additions & 0 deletions packages/core/fixtures/driver-test-suite/action-timeout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { worker } from "rivetkit";

// Short timeout worker
export const shortTimeoutWorker = worker({
onAuth: () => {},
state: { value: 0 },
options: {
action: {
timeout: 50, // 50ms timeout
},
},
actions: {
quickAction: async (c) => {
return "quick response";
},
slowAction: async (c) => {
// This action should timeout
await new Promise((resolve) => setTimeout(resolve, 100));
return "slow response";
},
},
});

// Long timeout worker
export const longTimeoutWorker = worker({
onAuth: () => {},
state: { value: 0 },
options: {
action: {
timeout: 200, // 200ms timeout
},
},
actions: {
delayedAction: async (c) => {
// This action should complete within timeout
await new Promise((resolve) => setTimeout(resolve, 100));
return "delayed response";
},
},
});

// Default timeout worker
export const defaultTimeoutWorker = worker({
onAuth: () => {},
state: { value: 0 },
actions: {
normalAction: async (c) => {
await new Promise((resolve) => setTimeout(resolve, 50));
return "normal response";
},
},
});

// Sync worker (timeout shouldn't apply)
export const syncTimeoutWorker = worker({
onAuth: () => {},
state: { value: 0 },
options: {
action: {
timeout: 50, // 50ms timeout
},
},
actions: {
syncAction: (c) => {
return "sync response";
},
},
});
Loading
Loading