https://github.com/jpb06/effect-github-stats
An effect layer to interact with github api
https://github.com/jpb06/effect-github-stats
effect-layer effect-ts github-stats octokit
Last synced: 9 months ago
JSON representation
An effect layer to interact with github api
- Host: GitHub
- URL: https://github.com/jpb06/effect-github-stats
- Owner: jpb06
- License: mit
- Archived: true
- Created: 2024-02-08T16:08:58.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-23T20:03:09.000Z (11 months ago)
- Last Synced: 2025-04-05T17:47:11.360Z (10 months ago)
- Topics: effect-layer, effect-ts, github-stats, octokit
- Language: TypeScript
- Homepage:
- Size: 504 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# effect-github-stats
[](https://github.dev/jpb06/effect-github-stats)



An [Effect](https://effect.website/) layer to interact with github api.
# 😺 This codebase has moved to [effect-octokit-layer](https://github.com/jpb06/effect-octokit-layer)
## âš¡ Access to github api
You first need to [create a github token](https://github.com/settings/tokens) with a scope related to your needs.
```bash
GITHUB_TOKEN="my-github-token"
```
## âš¡ Layer Api
### 🔶 Users
```typescript
import { OctokitLayer, OctokitLayerLive } from 'effect-github-stats';
const username = 'jpb06';
const [profile, repos, orgs, events] = await Effect.runPromise(
pipe(
Effect.all(
[
// Get user profile
OctokitLayer.user(username).profile(),
// Get user repos
OctokitLayer.user(username).repos(),
// Get user organizations
OctokitLayer.user(username).orgs(),
// Get user events
OctokitLayer.user(username).events(),
],
// Fetch all these in parallel
{ concurrency: 'unbounded' }
),
Effect.provide(OctokitLayerLive)
)
);
```
### 🔶 Organizations
```typescript
import { OctokitLayer, OctokitLayerLive } from 'effect-github-stats';
const orgs = await Effect.runPromise(
pipe(
// Get organization repos
OctokitLayer.org('my-org').repos(),
Effect.provide(OctokitLayerLive)
)
);
```
### 🔶 Repositories
```typescript
import { RepoArgs, OctokitLayer, OctokitLayerLive } from 'effect-github-stats';
const reactRepo: RepoArgs = {
owner: 'facebook',
name: 'react',
};
const [issues, pulls, issue34, pull5453, pull5453Reviews] =
await Effect.runPromise(
pipe(
Effect.all(
[
// Get all issues
OctokitLayer.repo(reactRepo).issues(),
// Get all pull requests
OctokitLayer.repo(reactRepo).pulls(),
// Get issue #34
OctokitLayer.repo(reactRepo).issue(34),
// Get pull request #5453 data
OctokitLayer.repo(reactRepo).pull(5453).details(),
// Get pull request #5453 reviews
OctokitLayer.repo(reactRepo).pull(5453).reviews(),
],
// Fetch all these in parallel
{ concurrency: 'unbounded' }
),
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:
```typescript
// 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](https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api?apiVersion=2022-11-28#dealing-with-secondary-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 (typically 60 seconds).