Make a GitHub request
You can use Octokit with Effect today. This repository contains a proposed adapter, an endpoint reference and executable experiments. The adapter exports no runtime API yet. The example below uses the two upstream packages directly.
In an empty directory, install the versions used in the reference:
bun add effect@4.1.5 octokit@5.0.5Save this as request.ts and run bun request.ts. It reads a public repository and prints octokit/octokit.js. A token is optional for this request.
import { Effect } from "effect"import { Octokit } from "octokit"
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })const repository = Effect.tryPromise({ try: signal => octokit.rest.repos.get({ owner: "octokit", repo: "octokit.js", request: { signal }, }), catch: (cause) => new Error("Could not read the repository", { cause }),})
const { data } = await Effect.runPromise(repository)console.log(data.full_name)Creating repository makes zero HTTP requests. Running it starts the request. Passing the fiber’s signal into Octokit lets interruption reach the active fetch. Octokit still applies the authentication, headers and retry settings of that client.
Read multiple pages · Handle a failed request · Find a REST endpoint · See the proposed adapter API