npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

effect-octokit-layer

v1.15.1

Published

Github Octokit layer for effect

Downloads

525

Readme

effect-octokit-layer

Open in Visual Studio Code npm bundle size Github workflow Quality Gate Status Maintainability Rating Security Rating Reliability Rating Vitest coverage Coverage Lines of Code Technical Debt Code Smells Bugs Vulnerabilities Duplicated Lines (%) Last commit

An Effect layer to interact with Github Octokit api.

⚡ Access to github api

You first need to create a github token with a scope related to your needs.

GITHUB_TOKEN="my-github-token"

⚡ Layer Api

🔶 Layer functions Types

The layer exposes functions with the following type:

import type { ConfigError, Effect } from 'effect';

type LayerErrors = GithubApiError | ApiRateLimitError | ConfigError.ConfigError;

type LayerFunction<TArgs, TResult> = (
  args: TArgs
) => Effect<TResult, LayerErrors, never>;

For example, getting user profile can be done with this function:

type GetUserProfile = (
  username: string
) => Effect<UserProfileResult, LayerErrors, never>;

🔶 Users

import { Effect, pipe } from 'effect';
import { OctokitLayer, OctokitLayerLive } from 'effect-octokit-layer';

const octokitUser = OctokitLayer.user('jpb06');

const [
  profile,
  repos,
  orgs,
  events,
  commits,
  issues,
  pullRequests,
  userPullRequestsCount,
  userCommitsCount,
  userIssuesCount,
] = await Effect.runPromise(
  pipe(
    Effect.all(
      [
        // Get user profile
        octokitUser.profile(),
        // Get user repos
        octokitUser.repos('all'),
        // Get user organizations
        octokitUser.orgs(),
        // Get user events
        octokitUser.events(),
        // Search in user commits (1000 results max)
        octokitUser.searchCommits(''),
        // Search in user issues (all, issue or pr) (1000 results max)
        octokitUser.searchIssues('pr', ''),
        // Search in user merged pull requests (1000 results max)
        octokitUser.searchPullRequests('merged', ''),
        // Get entities count
        octokitUser.getPullRequestsCount('draft'),
        octokitUser.getCommitsCount(),
        octokitUser.getIssuesCount('pr'),
      ],
      // Fetch all these in parallel
      { concurrency: 'unbounded' }
    ),
    Effect.provide(OctokitLayerLive)
  )
);

🔶 Organizations

import { Effect, pipe } from 'effect';
import { OctokitLayer, OctokitLayerLive } from 'effect-octokit-layer';

const orgs = await Effect.runPromise(
  pipe(
    // Get organization repos
    OctokitLayer.org('my-org').repos(),
    Effect.provide(OctokitLayerLive)
  )
);

🔶 Repositories

import { Effect, pipe } from 'effect';
import { OctokitLayer, OctokitLayerLive } from 'effect-octokit-layer';

const octokitRepo = OctokitLayer.repo({
  owner: 'facebook',
  repo: 'react',
});

const [
  languagesBytes,
  releases,
  tags,
  issues,
  issue34,
  issue34Comments,
  pulls,
  pullsComments,
] = await Effect.runPromise(
  pipe(
    Effect.all(
      [
        // Get bytes written per language
        octokitRepo.languages(),
        // Get releases
        octokitRepo.releases(),
        // Get tags
        octokitRepo.tags(),
        // Get all issues which are not pull requests and were created by user 'mcmullinboy15'
        octokitRepo.issues({
          state: 'all',
          excludePulls: true,
          creator: 'mcmullinboy15',
        }),
        // Get issue #34
        octokitRepo.issue(34).details(),
        // Get issue #34 comments
        octokitRepo.issue(34).comments(),
        // Get all pull requests matching head filter 'user:branch-name'
        octokitRepo.pulls.getAll({
          state: 'all',
          sort: 'created',
          direction: 'desc',
          head: 'jpb06:renovate/readme-package-icons-1.x',
        }),
        // Get all pull requests comments in repo
        octokitRepo.pulls.comments(),
      ],
      // Fetch all these in parallel
      { concurrency: 'unbounded' }
    ),
    Effect.provide(OctokitLayerLive)
  )
);

🔶 Pull requests

import { Effect, pipe } from 'effect';
import { OctokitLayer, OctokitLayerLive } from 'effect-octokit-layer';

const pull = OctokitLayer.repo({
  owner: 'facebook',
  repo: 'react',
}).pull(39);

const [details, comments, reviews, createdReview, deletedReview] =
  await Effect.runPromise(
    pipe(
      Effect.all(
        [
          // Pull request details
          pull.details(),
          // All the comments made on the pull request #39
          pull.comments(),
          // Pull request #39 reviews
          pull.reviews.get(),
          // Create a review
          pull.reviews.create({
            event: 'REQUEST_CHANGES',
            body: 'I think some points need to be adressed',
            comments: [
              {
                path: './src/cool.ts',
                body: "Shouldn't this file be renamed",
              },
            ],
          }),
          // Delete review #2
          pull.reviews.delete(2),
        ],
        { concurrency: 'unbounded' }
      ),
      Effect.provide(OctokitLayerLive)
    )
  );

🔶 Pull request comments

import { Effect, pipe } from 'effect';
import { RepoArgs, OctokitLayer, OctokitLayerLive } from 'effect-octokit-layer';

const reactRepo: RepoArgs = {
  owner: 'facebook',
  repo: 'react',
};
const pull = OctokitLayer.repo(reactRepo).pull(39);
const review = pull.review(2593339077);

const [createdComment, comments, deletedComment] = await Effect.runPromise(
  pipe(
    Effect.all([
      // Create a comment in review #2593339077 on pull request #39
      review.comments.create({
        path: './src',
        body: 'cool',
        commitId: 'ff',
      }),
      // Get review #2593339077 comments
      review.comments.get(),
      // Delete comment #1 in review #2593339077
      review.comments.delete(1),
    ]),
    Effect.provide(OctokitLayerLive)
  )
);

🔶 Parallelism and resilience

🧿 Concurrency

Default: 10

You can specify the concurrency parameter on calls doing several requests in parallel (paginated data). For example:

// Will fetch the first page and then 100 pages concurrently
OctokitLayer.repo({
  owner: 'facebook',
  name: 'react',
}).pulls(100);

Note that github api enforces api rate limits. Fetching too many results concurrently will cause an api rate limit. In that case, a warning will be displayed and the call will be attempted again after the time window provided by github api.

warning

⚡ github api documentation

Github api available endpoints