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, 07:15 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 * as Schema from "effect/Schema"; |
| 5 | import { Link, LinkNotFound } from "./Link.ts"; |
| 6 | |
| 7 | // #region show |
| 8 | // #region endpoints |
| 9 | const createLink = HttpApiEndpoint.post("create", "/links", { |
| 10 | payload: Schema.Struct({ url: Schema.String }), |
| 11 | success: Link, |
| 12 | }); |
| 13 | // #region get |
| 14 | |
| 15 | const getLink = HttpApiEndpoint.get("get", "/links/:code", { |
| 16 | params: Schema.Struct({ code: Schema.String }), |
| 17 | success: Link, |
| 18 | // #region getError |
| 19 | error: LinkNotFound, |
| 20 | // #endregion getError |
| 21 | }); |
| 22 | // #endregion get |
| 23 | // #region list |
| 24 | |
| 25 | const listLinks = HttpApiEndpoint.get("list", "/links", { |
| 26 | success: Schema.Array(Link), |
| 27 | }); |
| 28 | // #endregion list |
| 29 | // #endregion endpoints |
| 30 | // #region api |
| 31 | |
| 32 | export class ShortyApi extends HttpApi.make("ShortyApi").add( |
| 33 | HttpApiGroup.make("links").add(createLink, getLink, listLinks), |
| 34 | ) {} |
| 35 | // #endregion api |
| 36 | // #endregion show |