@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 29 lines 1.05 KB
Raw
1 import * as dns from "@distilled.cloud/cloudflare/dns";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import { type DnsAuth, makeHttpDnsBinding } from "./DnsHttp.ts";
5 import { ReadDns, type ReadDnsClient } from "./ReadDns.ts";
6
7 /** Runtime layer for {@link ReadDns}. */
8 export const ReadDnsHttp = Layer.effect(
9 ReadDns,
10 Effect.suspend(() =>
11 makeHttpDnsBinding({
12 permissionGroups: ["DNS Read"],
13 makeClient: dnsReadClient,
14 }),
15 ),
16 );
17
18 /** Build the read-only client over an injectable auth and zone id. */
19 export const dnsReadClient = (auth: DnsAuth, zoneId: Effect.Effect<string>): ReadDnsClient => {
20 const authorize = auth.authorize;
21 return {
22 getDnsRecord: Effect.fn("Cloudflare.DNS.getDnsRecord")(function* (dnsRecordId) {
23 return yield* authorize(dns.getRecord({ zoneId: yield* zoneId, dnsRecordId }));
24 }),
25 listDnsRecords: Effect.fn("Cloudflare.DNS.listDnsRecords")(function* (request) {
26 return yield* authorize(dns.listRecords({ zoneId: yield* zoneId, ...request }));
27 }),
28 };
29 };