Skip to content

Commit 1d4d4f6

Browse files
NathanFlurryjog1t
authored andcommitted
feat: routes
1 parent 25a00d4 commit 1d4d4f6

File tree

234 files changed

+10372
-722
lines changed

Some content is hidden

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

234 files changed

+10372
-722
lines changed

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Do not use cat, hexdump, perl, or sed. Always edit files directly.
2+
- If attempting to use Cargo, use `nix-shell --command 'cargo ...'`

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 1 deletion
Large diffs are not rendered by default.

docker/dev-full/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ services:
131131
restart: unless-stopped
132132
command: /usr/bin/rivet-guard
133133
environment:
134+
- RUST_LOG=debug
134135
- RUST_BACKTRACE=1
135136
- RUST_LOG_ANSI_COLOR=1
136137
- RIVET_OTEL_ENABLED=1

examples/functions/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# WebSocket
2+
3+
Simple WebSocket implementation.
4+
5+
## Prerequisites
6+
7+
- [Rivet CLI](https://rivet.gg/docs/setup)
8+
9+
## Deploying
10+
11+
```sh
12+
rivet login
13+
rivet deploy
14+
```
15+
16+
## Testing
17+
18+
```sh
19+
rivet deno --populate-env run -A ws_test.ts
20+
```
21+

examples/functions/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "example-functions",
3+
"version": "1.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"@rivet-gg/actor": "^5.1.2",
7+
"hono": "^4.6.17"
8+
}
9+
}

examples/functions/rivet.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"functions": {
3+
"simple": {
4+
"script": "ws.ts"
5+
}
6+
}
7+
}

examples/functions/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"types": ["node", "deno"],
7+
"allowSyntheticDefaultImports": true,
8+
"esModuleInterop": true,
9+
"noEmit": true,
10+
"isolatedModules": true
11+
},
12+
"include": ["**/*.ts"]
13+
}

examples/functions/ws.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { ActorContext } from "@rivet-gg/actor-core";
2+
import { Hono } from "hono";
3+
import { upgradeWebSocket } from "hono/deno";
4+
5+
// Setup Hono app
6+
const app = new Hono();
7+
8+
app.get("/", (c) => {
9+
return c.text("ok");
10+
});
11+
12+
13+
app.get("/health", (c) => {
14+
return c.text("ok");
15+
});
16+
17+
18+
// Start server
19+
export default {
20+
async start(ctx: ActorContext) {
21+
// Find port
22+
const portEnv = Deno.env.get("PORT_HTTP");
23+
if (!portEnv) {
24+
throw new Error("missing PORT_HTTP");
25+
}
26+
const port = Number.parseInt(portEnv);
27+
28+
// Start server
29+
console.log(`Listening on port ${port}`);
30+
const server = Deno.serve({ port }, app.fetch);
31+
await server.finished;
32+
},
33+
};
File renamed without changes.

0 commit comments

Comments
 (0)