The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Http from "alchemy/Http"; |
| 2 | import * as HttpApiBuilder from "effect/http-api/HttpApiBuilder"; |
| 3 | import type * as HttpApiGroup from "effect/http-api/HttpApiGroup"; |
| 4 | import * as HttpRouter from "effect/http/HttpRouter"; |
| 5 | import * as Layer from "effect/Layer"; |
| 6 | import { ShortyApi } from "./ShortyApi.ts"; |
| 7 | |
| 8 | /** Serve ShortyApi from a Worker's fetch, given the handlers for its endpoints. */ |
| 9 | export const serve = <E, R>( |
| 10 | handlers: Layer.Layer<HttpApiGroup.Service<"ShortyApi", "links">, E, R>, |
| 11 | ) => |
| 12 | HttpRouter.toHttpEffect( |
| 13 | HttpApiBuilder.layer(ShortyApi).pipe( |
| 14 | Layer.provide(handlers), |
| 15 | Layer.provide(Http.Platform), |
| 16 | Layer.provide(HttpRouter.cors()), |
| 17 | ), |
| 18 | ); |