Skip to content

Provide an Octokit client

Adapter design. This page specifies the unpublished adapter. Run a request with Octokit and Effect.

Offer an ordinary service for the standard Octokit facade, a generic fromOctokit(client) value constructor, and a layer from an existing client. A plugin-rich instance retains its concrete type in the value facade. A single fixed service identifier cannot preserve a different generic per injection: provide a caller-defined typed service key/layer factory for applications that need plugins through the environment. A bare Core service must not advertise .rest or pagination.

A borrowed client keeps its auth cache, hooks, transport, logger and base URL. A layer that constructs a client creates it once per acquisition and releases the resources it allocated. Layer memoization is scoped to the application’s composition. Avoid process-wide singletons and cross-installation service lookup. Read configuration/redacted secrets at acquisition only when asked to construct a client.

const client = fromOctokit(installationOctokit);
const pr = client.rest.pulls.get({ owner, repo, pull_number });

Provide narrow capability interfaces for application tests so a consumer can fake its one dependency without fabricating an entire Octokit class. Preserve ordinary Effect environment inference and avoid nested runPromise or a hidden runtime. Use a single supported Effect major per release line; the research baseline is Effect 4.1.5. Effect services