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

main
ts 43 lines 1.25 KB
Raw
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 * as HttpApiSchema from "effect/http-api/HttpApiSchema";
5 import * as Schema from "effect/Schema";
6
7 export class Note extends Schema.Class<Note>("Note")({
8 id: Schema.String,
9 title: Schema.String,
10 source: Schema.String,
11 createdAt: Schema.Number,
12 }) {}
13
14 export class NotesList extends Schema.Class<NotesList>("NotesList")({
15 notes: Schema.Array(Note),
16 }) {}
17
18 export const listNotes = HttpApiEndpoint.get("listNotes", "/notes", {
19 success: NotesList,
20 });
21
22 export const createNote = HttpApiEndpoint.post("createNote", "/notes", {
23 success: Note.pipe(HttpApiSchema.status(201)),
24 payload: Schema.Struct({
25 title: Schema.String,
26 }),
27 });
28
29 export const deleteNote = HttpApiEndpoint.delete("deleteNote", "/notes/:id", {
30 params: Schema.Struct({
31 id: Schema.String,
32 }),
33 success: HttpApiSchema.NoContent,
34 });
35
36 export class BackendGroup extends HttpApiGroup.make("Backend").add(
37 listNotes,
38 createNote,
39 deleteNote,
40 ) {}
41
42 /** Backend Worker HttpApi — D1 only. KV lives on the vinext frontend. */
43 export class BackendApi extends HttpApi.make("BackendApi").add(BackendGroup) {}