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 HttpApi from "effect/http-api/HttpApi"; |
| 2 | import * as HttpApiEndpoint from "effect/http-api/HttpApiEndpoint"; |
| 3 | import * as HttpApiGroup from "effect/http-api/HttpApiGroup"; |
| 4 | import { Rpc, RpcGroup } from "effect/rpc"; |
| 5 | import * as Schema from "effect/Schema"; |
| 6 | |
| 7 | export class Task extends Schema.Class<Task>("Task")({ |
| 8 | id: Schema.String, |
| 9 | title: Schema.String, |
| 10 | }) {} |
| 11 | |
| 12 | export class TaskNotFound extends Schema.TaggedError<TaskNotFound>()( |
| 13 | "TaskNotFound", |
| 14 | { id: Schema.String }, |
| 15 | { httpApiStatus: 404 }, |
| 16 | ) {} |
| 17 | |
| 18 | export class TaskRpcs extends RpcGroup.make( |
| 19 | Rpc.make("getTask", { payload: { id: Schema.String }, success: Task, error: TaskNotFound }), |
| 20 | Rpc.make("countTasks", { payload: { to: Schema.Number }, success: Schema.Number, stream: true }), |
| 21 | ) {} |
| 22 | |
| 23 | export class TasksGroup extends HttpApiGroup.make("Tasks").add( |
| 24 | HttpApiEndpoint.get("getTask", "/tasks/:id", { |
| 25 | params: Schema.Struct({ id: Schema.String }), |
| 26 | success: Task, |
| 27 | error: TaskNotFound, |
| 28 | }), |
| 29 | ) {} |
| 30 | |
| 31 | export class TaskApi extends HttpApi.make("TaskApi").add(TasksGroup) {} |
| 32 | |
| 33 | /** The one task every server knows. */ |
| 34 | export const lookup = (id: string, from: string) => |
| 35 | id === "t1" ? new Task({ id, title: `from ${from}` }) : undefined; |