@rsalianto/git-heatmap-next 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/package.json +5 -2
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @rsalianto/git-heatmap-next
|
|
2
|
+
|
|
3
|
+
Next.js App Router route handler factories for serving GitHub and GitLab contribution data.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @rsalianto/git-heatmap-next @rsalianto/git-heatmap-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### GitHub
|
|
14
|
+
|
|
15
|
+
Create `app/api/contributions/github/route.ts`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createGitHubHandler } from "@rsalianto/git-heatmap-next";
|
|
19
|
+
|
|
20
|
+
export const GET = createGitHubHandler({
|
|
21
|
+
username: "your-github-username",
|
|
22
|
+
token: process.env.GITHUB_TOKEN,
|
|
23
|
+
revalidate: 3600, // cache in seconds (default: 3600)
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### GitLab
|
|
28
|
+
|
|
29
|
+
Create `app/api/contributions/gitlab/route.ts`:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { createGitLabHandler } from "@rsalianto/git-heatmap-next";
|
|
33
|
+
|
|
34
|
+
export const GET = createGitLabHandler({
|
|
35
|
+
username: "your-gitlab-username",
|
|
36
|
+
token: process.env.GITLAB_TOKEN, // optional for public profiles
|
|
37
|
+
baseUrl: "https://gitlab.com", // optional, defaults to gitlab.com
|
|
38
|
+
revalidate: 3600,
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then use with `@rsalianto/git-heatmap-react`:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { GitHeatmap } from "@rsalianto/git-heatmap-react";
|
|
46
|
+
|
|
47
|
+
export default function Page() {
|
|
48
|
+
return <GitHeatmap apiUrl="/api/contributions/github" />;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Options
|
|
53
|
+
|
|
54
|
+
### `createGitHubHandler(options)`
|
|
55
|
+
|
|
56
|
+
| Option | Type | Description |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `username` | `string` | GitHub username |
|
|
59
|
+
| `token` | `string` | GitHub personal access token. Falls back to `GITHUB_TOKEN` env var |
|
|
60
|
+
| `revalidate` | `number` | `Cache-Control s-maxage` in seconds (default: `3600`) |
|
|
61
|
+
| `levels` | `LevelConfig[]` | Custom level thresholds |
|
|
62
|
+
|
|
63
|
+
### `createGitLabHandler(options)`
|
|
64
|
+
|
|
65
|
+
| Option | Type | Description |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `username` | `string` | GitLab username |
|
|
68
|
+
| `token` | `string` | GitLab personal access token. Falls back to `GITLAB_TOKEN` env var |
|
|
69
|
+
| `baseUrl` | `string` | GitLab instance URL (default: `https://gitlab.com`) |
|
|
70
|
+
| `revalidate` | `number` | `Cache-Control s-maxage` in seconds (default: `3600`) |
|
|
71
|
+
| `levels` | `LevelConfig[]` | Custom level thresholds |
|
|
72
|
+
|
|
73
|
+
## Response format
|
|
74
|
+
|
|
75
|
+
Both handlers return `HeatmapData` JSON:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"totalContributions": 312,
|
|
80
|
+
"weeks": [{ "days": [{ "date": "2024-01-01", "count": 5, "level": 2 }] }],
|
|
81
|
+
"source": "github"
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Related packages
|
|
86
|
+
|
|
87
|
+
- [`@rsalianto/git-heatmap-react`](https://www.npmjs.com/package/@rsalianto/git-heatmap-react) — React component
|
|
88
|
+
- [`@rsalianto/git-heatmap-core`](https://www.npmjs.com/package/@rsalianto/git-heatmap-core) — Core utilities
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsalianto/git-heatmap-next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Next.js App Router route handler factory for git-heatmap",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
"require": "./dist/index.js"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"files": [
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
17
20
|
"sideEffects": false,
|
|
18
21
|
"scripts": {
|
|
19
22
|
"build": "tsup",
|