@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, 06:00 UTC

main
ts 39 lines 1.22 KB
Raw
1 import * as Fly from "@alchemy.run/fly";
2 import * as Effect from "effect/Effect";
3 import * as FileSystem from "effect/FileSystem";
4 import { HttpServerRequest } from "effect/http/HttpServerRequest";
5 import * as HttpServerResponse from "effect/http/HttpServerResponse";
6
7 /**
8 * HTTP Sprite: writes a marker during init and serves it back.
9 */
10 export default class Box extends Fly.Sprite<Box>()(
11 "Box",
12 {
13 main: import.meta.url,
14 urlAuth: "public",
15 port: 3000,
16 },
17 Effect.gen(function* () {
18 const fs = yield* FileSystem.FileSystem;
19
20 return {
21 fetch: Effect.gen(function* () {
22 const request = yield* HttpServerRequest;
23 const url = new URL(request.url, "http://sprite");
24 if (url.pathname === "/health") {
25 return yield* HttpServerResponse.json({ ok: true });
26 }
27 yield* fs.makeDirectory("/tmp", { recursive: true }).pipe(Effect.orDie);
28 yield* fs
29 .writeFileString("/tmp/alchemy-sprite.txt", "hello-from-sprite")
30 .pipe(Effect.orDie);
31 const text = yield* fs.readFileString("/tmp/alchemy-sprite.txt").pipe(Effect.orDie);
32 return yield* HttpServerResponse.json({
33 ok: true,
34 text,
35 });
36 }),
37 };
38 }),
39 ) {}