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
| 1 | import * as zoneRrsets from "@distilled.cloud/hetzner/zone_rrsets"; |
| 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 | makeClient: dnsReadClient, |
| 13 | }), |
| 14 | ), |
| 15 | ); |
| 16 | |
| 17 | /** Build the read-only client over an injectable auth and zone id. */ |
| 18 | export const dnsReadClient = (auth: DnsAuth, zoneId: Effect.Effect<number>): ReadDnsClient => { |
| 19 | const authorize = auth.authorize; |
| 20 | return { |
| 21 | getRecordSet: Effect.fn("Hetzner.DNS.getRecordSet")(function* (name, type) { |
| 22 | return yield* authorize( |
| 23 | zoneRrsets.getZoneRrset({ |
| 24 | id_or_name: String(yield* zoneId), |
| 25 | rr_name: name, |
| 26 | rr_type: type, |
| 27 | }), |
| 28 | ); |
| 29 | }), |
| 30 | listRecordSets: Effect.fn("Hetzner.DNS.listRecordSets")(function* (request) { |
| 31 | return yield* authorize( |
| 32 | zoneRrsets.listZoneRrsets({ |
| 33 | id_or_name: String(yield* zoneId), |
| 34 | ...request, |
| 35 | }), |
| 36 | ); |
| 37 | }), |
| 38 | }; |
| 39 | }; |