@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 24 lines 958 Bytes
Raw
1 import * as Effect from "effect/Effect";
2 import { HttpServerRequest } from "effect/http/HttpServerRequest";
3 import * as HttpServerResponse from "effect/http/HttpServerResponse";
4
5 /**
6 * The effectful MicroVM server, shared verbatim by the bun and node effectful
7 * images so the only thing that differs between them is the JS runtime. Exposes
8 * a raw `fetch` handler (with an `/echo` route) and a typed RPC `hello` method.
9 */
10 export const effectfulImpl = Effect.gen(function* () {
11 return {
12 fetch: Effect.gen(function* () {
13 const request = yield* HttpServerRequest;
14 const url = new URL(request.url, "http://microvm");
15 if (url.pathname === "/echo") {
16 return yield* HttpServerResponse.json({
17 message: url.searchParams.get("message") ?? "",
18 });
19 }
20 return HttpServerResponse.text("hello from effectful microvm");
21 }),
22 hello: (message: string) => Effect.succeed(`hello, ${message}!`),
23 };
24 });