@devries-cameron20 / t3code Mirror · read-only
Fork 0

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, 04:45 UTC

main
ts 27 lines 851 Bytes
Raw
1 import * as Context from "effect/Context";
2 import * as Effect from "effect/Effect";
3 import * as HttpApiClient from "effect/http-api/HttpApiClient";
4 import * as FetchHttpClient from "effect/http/FetchHttpClient";
5 import * as Layer from "effect/Layer";
6 import { BackendApi } from "./BackendApi.ts";
7 import { env } from "./Env.ts";
8
9 const backendClient = HttpApiClient.make(BackendApi, {
10 baseUrl: "http://localhost",
11 }).pipe(
12 Effect.provide(
13 FetchHttpClient.layer.pipe(
14 Layer.provide(
15 Layer.succeed(FetchHttpClient.Fetch, ((input, init) =>
16 env.BACKEND.fetch(input, init)) as typeof globalThis.fetch),
17 ),
18 ),
19 ),
20 );
21
22 export class BackendClient extends Context.Service<
23 BackendClient,
24 Effect.Success<typeof backendClient>
25 >()("BackendClient") {
26 static Default = Layer.effect(BackendClient, backendClient);
27 }