An ATProto PDS running on Rivet?
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add http gateway and rivet http handler.

Zicklag 3c095967 f2a670d8

+141 -12
+12
.editorconfig
··· 1 + # EditorConfig is awesome: https://EditorConfig.org 2 + 3 + # top-most EditorConfig file 4 + root = true 5 + 6 + [*] 7 + indent_style = space 8 + indent_size = 2 9 + end_of_line = lf 10 + charset = utf-8 11 + trim_trailing_whitespace = false 12 + insert_final_newline = false
main.ts start_runner.ts
+5 -1
package.json
··· 5 5 "main": "main.ts", 6 6 "type": "module", 7 7 "scripts": { 8 - "start": "npx tsx main.ts" 8 + "runner": "npx tsx start_runner.ts", 9 + "gateway": "npx tsx start_gateway.ts" 9 10 }, 10 11 "keywords": [], 11 12 "author": "Zicklag", 12 13 "license": "ISC", 13 14 "packageManager": "pnpm@10.30.3", 14 15 "devDependencies": { 16 + "@types/node": "^25.3.5", 15 17 "tsx": "^4.21.0" 16 18 }, 17 19 "dependencies": { 18 20 "@hono/node-server": "^1.19.11", 19 21 "@hono/node-ws": "^1.3.0", 22 + "@whatwg-node/server": "^0.10.18", 23 + "hono": "^4.12.5", 20 24 "rivetkit": "^2.1.6" 21 25 } 22 26 }
+94
pnpm-lock.yaml
··· 14 14 '@hono/node-ws': 15 15 specifier: ^1.3.0 16 16 version: 1.3.0(@hono/node-server@1.19.11(hono@4.12.5))(hono@4.12.5) 17 + '@whatwg-node/server': 18 + specifier: ^0.10.18 19 + version: 0.10.18 20 + hono: 21 + specifier: ^4.12.5 22 + version: 4.12.5 17 23 rivetkit: 18 24 specifier: ^2.1.6 19 25 version: 2.1.6(@hono/node-server@1.19.11(hono@4.12.5))(@hono/node-ws@1.3.0(@hono/node-server@1.19.11(hono@4.12.5))(hono@4.12.5))(@standard-schema/spec@1.0.0)(ws@8.19.0) 20 26 devDependencies: 27 + '@types/node': 28 + specifier: ^25.3.5 29 + version: 25.3.5 21 30 tsx: 22 31 specifier: ^4.21.0 23 32 version: 4.21.0 ··· 58 67 resolution: {integrity: sha512-l2M+Z8DO2vbvADOBNLbbh9y5ST1RY5sqkWOg/58GkUPBYou/cuNZ68SGQ644f1CvZ8kcOxyZtw06+dxWHIoN/w==} 59 68 cpu: [x64] 60 69 os: [win32] 70 + 71 + '@envelop/instrumentation@1.0.0': 72 + resolution: {integrity: sha512-cxgkB66RQB95H3X27jlnxCRNTmPuSTgmBAq6/4n2Dtv4hsk4yz8FadA1ggmd0uZzvKqWD6CR+WFgTjhDqg7eyw==} 73 + engines: {node: '>=18.0.0'} 61 74 62 75 '@esbuild/aix-ppc64@0.27.3': 63 76 resolution: {integrity: sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==} ··· 215 228 cpu: [x64] 216 229 os: [win32] 217 230 231 + '@fastify/busboy@3.2.0': 232 + resolution: {integrity: sha512-m9FVDXU3GT2ITSe0UaMA5rU3QkfC/UXtCU8y0gSN/GugTqtVldOBWIB5V6V3sbmenVZUIpU6f+mPEO2+m5iTaA==} 233 + 218 234 '@hono/node-server@1.19.11': 219 235 resolution: {integrity: sha512-dr8/3zEaB+p0D2n/IUrlPF1HZm586qgJNXK1a9fhg/PzdtkK7Ksd5l312tJX2yBuALqDYBlG20QEbayqPyxn+g==} 220 236 engines: {node: '>=18.14.1'} ··· 292 308 '@standard-schema/spec@1.0.0': 293 309 resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==} 294 310 311 + '@types/node@25.3.5': 312 + resolution: {integrity: sha512-oX8xrhvpiyRCQkG1MFchB09f+cXftgIXb3a7UUa4Y3wpmZPw5tyZGTLWhlESOLq1Rq6oDlc8npVU2/9xiCuXMA==} 313 + 295 314 '@types/retry@0.12.2': 296 315 resolution: {integrity: sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow==} 297 316 317 + '@whatwg-node/disposablestack@0.0.6': 318 + resolution: {integrity: sha512-LOtTn+JgJvX8WfBVJtF08TGrdjuFzGJc4mkP8EdDI8ADbvO7kiexYep1o8dwnt0okb0jYclCDXF13xU7Ge4zSw==} 319 + engines: {node: '>=18.0.0'} 320 + 321 + '@whatwg-node/fetch@0.10.13': 322 + resolution: {integrity: sha512-b4PhJ+zYj4357zwk4TTuF2nEe0vVtOrwdsrNo5hL+u1ojXNhh1FgJ6pg1jzDlwlT4oBdzfSwaBwMCtFCsIWg8Q==} 323 + engines: {node: '>=18.0.0'} 324 + 325 + '@whatwg-node/node-fetch@0.8.5': 326 + resolution: {integrity: sha512-4xzCl/zphPqlp9tASLVeUhB5+WJHbuWGYpfoC2q1qh5dw0AqZBW7L27V5roxYWijPxj4sspRAAoOH3d2ztaHUQ==} 327 + engines: {node: '>=18.0.0'} 328 + 329 + '@whatwg-node/promise-helpers@1.3.2': 330 + resolution: {integrity: sha512-Nst5JdK47VIl9UcGwtv2Rcgyn5lWtZ0/mhRQ4G8NN2isxpq2TO30iqHzmwoJycjWuyUfg3GFXqP/gFHXeV57IA==} 331 + engines: {node: '>=16.0.0'} 332 + 333 + '@whatwg-node/server@0.10.18': 334 + resolution: {integrity: sha512-kMwLlxUbduttIgaPdSkmEarFpP+mSY8FEm+QWMBRJwxOHWkri+cxd8KZHO9EMrB9vgUuz+5WEaCawaL5wGVoXg==} 335 + engines: {node: '>=18.0.0'} 336 + 298 337 atomic-sleep@1.0.0: 299 338 resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} 300 339 engines: {node: '>=8.0.0'} ··· 448 487 thread-stream@3.1.0: 449 488 resolution: {integrity: sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==} 450 489 490 + tslib@2.8.1: 491 + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} 492 + 451 493 tsx@4.21.0: 452 494 resolution: {integrity: sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==} 453 495 engines: {node: '>=18.0.0'} 454 496 hasBin: true 455 497 498 + undici-types@7.18.2: 499 + resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==} 500 + 501 + urlpattern-polyfill@10.1.0: 502 + resolution: {integrity: sha512-IGjKp/o0NL3Bso1PymYURCJxMPNAf/ILOpendP9f5B6e1rTJgdgiOvgfoT8VxCAdY+Wisb9uhGaJJf3yZ2V9nw==} 503 + 456 504 uuid@12.0.0: 457 505 resolution: {integrity: sha512-USe1zesMYh4fjCA8ZH5+X5WIVD0J4V1Jksm1bFTVBX2F/cwSXt0RO5w/3UXbdLKmZX65MiWV+hwhSS8p6oBTGA==} 458 506 hasBin: true ··· 509 557 510 558 '@cbor-extract/cbor-extract-win32-x64@2.2.0': 511 559 optional: true 560 + 561 + '@envelop/instrumentation@1.0.0': 562 + dependencies: 563 + '@whatwg-node/promise-helpers': 1.3.2 564 + tslib: 2.8.1 512 565 513 566 '@esbuild/aix-ppc64@0.27.3': 514 567 optional: true ··· 588 641 '@esbuild/win32-x64@0.27.3': 589 642 optional: true 590 643 644 + '@fastify/busboy@3.2.0': {} 645 + 591 646 '@hono/node-server@1.19.11(hono@4.12.5)': 592 647 dependencies: 593 648 hono: 4.12.5 ··· 672 727 vbare: 0.0.4 673 728 674 729 '@standard-schema/spec@1.0.0': {} 730 + 731 + '@types/node@25.3.5': 732 + dependencies: 733 + undici-types: 7.18.2 675 734 676 735 '@types/retry@0.12.2': {} 677 736 737 + '@whatwg-node/disposablestack@0.0.6': 738 + dependencies: 739 + '@whatwg-node/promise-helpers': 1.3.2 740 + tslib: 2.8.1 741 + 742 + '@whatwg-node/fetch@0.10.13': 743 + dependencies: 744 + '@whatwg-node/node-fetch': 0.8.5 745 + urlpattern-polyfill: 10.1.0 746 + 747 + '@whatwg-node/node-fetch@0.8.5': 748 + dependencies: 749 + '@fastify/busboy': 3.2.0 750 + '@whatwg-node/disposablestack': 0.0.6 751 + '@whatwg-node/promise-helpers': 1.3.2 752 + tslib: 2.8.1 753 + 754 + '@whatwg-node/promise-helpers@1.3.2': 755 + dependencies: 756 + tslib: 2.8.1 757 + 758 + '@whatwg-node/server@0.10.18': 759 + dependencies: 760 + '@envelop/instrumentation': 1.0.0 761 + '@whatwg-node/disposablestack': 0.0.6 762 + '@whatwg-node/fetch': 0.10.13 763 + '@whatwg-node/promise-helpers': 1.3.2 764 + tslib: 2.8.1 765 + 678 766 atomic-sleep@1.0.0: {} 679 767 680 768 cbor-extract@2.2.0: ··· 860 948 dependencies: 861 949 real-require: 0.2.0 862 950 951 + tslib@2.8.1: {} 952 + 863 953 tsx@4.21.0: 864 954 dependencies: 865 955 esbuild: 0.27.3 866 956 get-tsconfig: 4.13.6 867 957 optionalDependencies: 868 958 fsevents: 2.3.3 959 + 960 + undici-types@7.18.2: {} 961 + 962 + urlpattern-polyfill@10.1.0: {} 869 963 870 964 uuid@12.0.0: {} 871 965
+9 -11
registry.ts
··· 1 1 import { actor, setup } from "rivetkit"; 2 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 - }, 3 + // Create an HTTP actor for handling requests 4 + export const http = actor({ 5 + // Create a raw request handler 6 + onRequest(_c, req) { 7 + // Return whatever URL comes from the request as the text body 8 + return new Response(`Url: ${req.url}`); 9 + }, 12 10 }); 13 11 14 12 export const registry = setup({ 15 - use: { counter }, 16 - }); 13 + use: { http }, 14 + });
+21
start_gateway.ts
··· 1 + import { createClient } from "rivetkit/client"; 2 + import { registry } from "./registry"; 3 + import { serve } from "@hono/node-server"; 4 + import { Hono } from "hono"; 5 + 6 + // Connect to Rivet 7 + const client = createClient<typeof registry>(); 8 + 9 + // Get the http handler actor 10 + const http = client.http.getOrCreate("main"); 11 + 12 + // Create a webserver 13 + const app = new Hono(); 14 + 15 + // Forward all requests to the http handler 16 + app.all("*", (c) => http.fetch(c.req.raw)); 17 + 18 + // Run the node.js webserver 19 + serve(app, (info) => { 20 + console.log(`Listening on http://localhost:${info.port}`); 21 + });