effect-github-stats v1.0.35
effect-github-stats
An Effect layer to interact with github 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
🔶 Users
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
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
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:
// 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 (typically 60 seconds).
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago