@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 33 lines 1.07 KB
Raw
1 import * as Issues from "@distilled.cloud/github/issues";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as BindingHttp from "./BindingHttp.ts";
5 import { IssueNotFound } from "./Errors.ts";
6 import { GetIssue, type GetIssueRequest } from "./GetIssue.ts";
7
8 export const getIssueOperation = BindingHttp.operation(
9 "issues.get",
10 (repo) => (request: GetIssueRequest) =>
11 Issues.get({ owner: repo.owner, repo: repo.repository, ...request }).pipe(
12 Effect.catchTag("NotFound", () =>
13 Effect.fail(
14 new IssueNotFound({
15 owner: repo.owner,
16 repository: repo.repository,
17 number: request.issue_number,
18 }),
19 ),
20 ),
21 ),
22 );
23
24 /**
25 * Token-backed implementation of {@link GetIssue}. Provide it on a Worker or
26 * Function: it captures a `GitHub.PersonalAccessToken` for the host and binds
27 * the token and the repository into it.
28 *
29 * @layer
30 * @product Issue
31 * @provides GitHub.GetIssue
32 */
33 export const GetIssueHttp = Layer.effect(GetIssue, BindingHttp.make(getIssueOperation));