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
| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as HttpApiBuilder from "effect/http-api/HttpApiBuilder"; |
| 3 | import * as Stream from "effect/Stream"; |
| 4 | import { lookup, TaskApi, TaskNotFound, TaskRpcs } from "./schema.ts"; |
| 5 | |
| 6 | export const rpcHandlers = (from: string) => |
| 7 | TaskRpcs.toLayer({ |
| 8 | getTask: ({ id }) => { |
| 9 | const task = lookup(id, from); |
| 10 | return task ? Effect.succeed(task) : Effect.fail(new TaskNotFound({ id })); |
| 11 | }, |
| 12 | countTasks: ({ to }) => Stream.range(1, to), |
| 13 | }); |
| 14 | |
| 15 | export const httpApiHandlers = (from: string) => |
| 16 | HttpApiBuilder.group(TaskApi, "Tasks", (handlers) => |
| 17 | handlers.handle("getTask", ({ params }) => { |
| 18 | const task = lookup(params.id, from); |
| 19 | return task ? Effect.succeed(task) : Effect.fail(new TaskNotFound({ id: params.id })); |
| 20 | }), |
| 21 | ); |