The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as HttpApiClient from "effect/http-api/HttpApiClient"; |
| 3 | import * as FetchHttpClient from "effect/http/FetchHttpClient"; |
| 4 | import { ShortyApi } from "./ShortyApi.ts"; |
| 5 | |
| 6 | export const API_URL = import.meta.env.VITE_API_URL as string; |
| 7 | |
| 8 | // A typed client derived from the same `ShortyApi` value the Worker serves. |
| 9 | const makeClient = HttpApiClient.make(ShortyApi, { baseUrl: API_URL }); |
| 10 | |
| 11 | export const call = <A, E>(f: (client: Effect.Success<typeof makeClient>) => Effect.Effect<A, E>) => |
| 12 | Effect.runPromise(makeClient.pipe(Effect.flatMap(f), Effect.provide(FetchHttpClient.layer))); |