@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, 06:00 UTC

main
ts 33 lines 1.16 KB
Raw
1 import * as Effect from "effect/Effect"
2 import * as HttpClient from "effect/http/HttpClient"
3 import * as HttpClientRequest from "effect/http/HttpClientRequest"
4 import type * as Redacted from "effect/Redacted"
5
6 export interface GitHubRepository {
7 readonly repository: string
8 readonly token: Redacted.Redacted<string>
9 }
10
11 /**
12 * A GitHub REST client for `repository`. Paths are relative to
13 * `/repos/<owner>/<name>` and non-2xx responses are errors.
14 */
15 export const makeClient = (
16 repository: string,
17 token: Redacted.Redacted<string>
18 ): Effect.Effect<HttpClient.HttpClient, never, HttpClient.HttpClient> =>
19 Effect.gen(function*() {
20 const client = yield* HttpClient.HttpClient
21 return client.pipe(
22 HttpClient.mapRequest((request) =>
23 request.pipe(
24 HttpClientRequest.prependUrl(`https://api.github.com/repos/${repository}`),
25 HttpClientRequest.bearerToken(token),
26 HttpClientRequest.accept("application/vnd.github+json"),
27 HttpClientRequest.setHeader("x-github-api-version", "2022-11-28"),
28 HttpClientRequest.setHeader("user-agent", "effect-npm-promote")
29 )
30 ),
31 HttpClient.filterStatusOk
32 )
33 })