@jcbhmr/ungh 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jacob Hummer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # ungh.cc client
2
+
3
+ 🐙 [ungh.cc](https://ungh.cc) API client for JavaScript
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install @jcbhmr/ungh
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import Ungh from "@jcbhmr/ungh";
15
+
16
+ const ungh = new Ungh();
17
+ console.log(await ungh.orgs.get("github"));
18
+ console.log(await ungh.users.getByUsername("octocat"));
19
+ console.log(await ungh.repos.listForOrg("github"));
20
+ console.log(await ungh.repos.listForUser("octocat"));
21
+ console.log(await ungh.repos.getLatestRelease("nodejs", "node"));
22
+ console.log(await ungh.repos.listReleases("nodejs", "node"));
23
+ ```
24
+
25
+ ## Development
26
+
27
+ ![Vite+](https://img.shields.io/badge/Vite+-9135FF?style=for-the-badge&logo=Vite&logoColor=FFFFFF)
@@ -0,0 +1,114 @@
1
+ //#region src/index.d.ts
2
+ interface Options {
3
+ baseURL?: string | URL;
4
+ userAgent?: string;
5
+ fetch?: typeof globalThis.fetch;
6
+ }
7
+ declare namespace Users {
8
+ interface User {
9
+ id: number;
10
+ username: string;
11
+ name: string | null;
12
+ twitter: string | null;
13
+ avatar: string;
14
+ }
15
+ interface GetByUsername {
16
+ user: User;
17
+ }
18
+ interface Find {
19
+ user: User;
20
+ }
21
+ }
22
+ declare namespace Repos {
23
+ interface Repo {
24
+ id: number;
25
+ name: string;
26
+ repo: string;
27
+ description: string | null;
28
+ createdAt: string | null;
29
+ updatedAt: string | null;
30
+ pushedAt: string | null;
31
+ stars: number;
32
+ watchers: number;
33
+ forks: number;
34
+ defaultBranch: string;
35
+ }
36
+ interface ListForOrg {
37
+ repos: Repo[];
38
+ }
39
+ interface ListForUser {
40
+ repos: Repo[];
41
+ }
42
+ interface Get {
43
+ repo: Repo;
44
+ }
45
+ interface ListBranches {
46
+ branches: {
47
+ name: string;
48
+ commit: {
49
+ sha: string;
50
+ url: string;
51
+ };
52
+ protected: boolean;
53
+ }[];
54
+ }
55
+ interface Release {
56
+ id: number;
57
+ tag: string;
58
+ author: string;
59
+ name: string | null;
60
+ draft: boolean;
61
+ prerelease: boolean;
62
+ createdAt: string;
63
+ publishedAt: string | null;
64
+ markdown: string;
65
+ html: string;
66
+ assets: {
67
+ contentType: string;
68
+ size: number;
69
+ createdAt: string;
70
+ updatedAt: string;
71
+ downloadCount: number;
72
+ downloadUrl: string;
73
+ }[];
74
+ }
75
+ interface GetLatestRelease {
76
+ release: Release;
77
+ }
78
+ interface ListReleases {
79
+ releases: Release[];
80
+ }
81
+ interface ListContributors {
82
+ contributors: {
83
+ id: number;
84
+ username: string;
85
+ contributions: number;
86
+ }[];
87
+ }
88
+ interface GetReadme {
89
+ markdown: string;
90
+ html: string;
91
+ }
92
+ }
93
+ declare class Ungh {
94
+ #private;
95
+ constructor(options?: Options);
96
+ orgs: {
97
+ get: (org: string) => Promise<any>;
98
+ };
99
+ users: {
100
+ getByUsername: (username: string) => Promise<Users.GetByUsername>;
101
+ find: (query: string) => Promise<Users.Find>;
102
+ };
103
+ repos: {
104
+ listForOrg: (org: string) => Promise<Repos.ListForOrg>;
105
+ listForUser: (username: string) => Promise<Repos.ListForUser>;
106
+ get: (owner: string, repo: string) => Promise<Repos.Get>;
107
+ listBranches: (owner: string, repo: string) => Promise<Repos.ListBranches>;
108
+ getLatestRelease: (owner: string, repo: string) => Promise<Repos.GetLatestRelease>;
109
+ listReleases: (owner: string, repo: string) => Promise<Repos.ListReleases>;
110
+ listContributors: (owner: string, repo: string) => Promise<Repos.ListContributors>;
111
+ };
112
+ }
113
+ //#endregion
114
+ export { Options, Repos, Users, Ungh as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,46 @@
1
+ //#region src/index.ts
2
+ var Ungh = class {
3
+ #baseURL;
4
+ #userAgent;
5
+ #fetch;
6
+ constructor(options = {}) {
7
+ const baseURL = options.baseURL !== void 0 ? options.baseURL.toString() : "https://ungh.cc/";
8
+ const { userAgent, fetch = globalThis.fetch } = options;
9
+ this.#baseURL = baseURL;
10
+ this.#userAgent = userAgent;
11
+ this.#fetch = fetch;
12
+ }
13
+ async #fetchJSON(url) {
14
+ const response = await this.#fetch(new URL(url, this.#baseURL), {
15
+ headers: {
16
+ "User-Agent": this.#userAgent,
17
+ Accept: "application/json"
18
+ },
19
+ signal: AbortSignal.timeout(3e4)
20
+ });
21
+ if (response.status !== 200) throw new DOMException(`Unexpected response status: ${response.url} responded with ${response.status}`);
22
+ const contentType = response.headers.get("Content-Type");
23
+ if (contentType !== "application/json") throw new DOMException(`Unexpected content type: ${response.url} responded with ${contentType}`);
24
+ return await response.json();
25
+ }
26
+ async #fetchRouteJSON(template, ...substitutions) {
27
+ const route = String.raw({ raw: template }, ...substitutions.map((x) => encodeURIComponent(x)));
28
+ return await this.#fetchJSON(route);
29
+ }
30
+ orgs = { get: (org) => this.#fetchRouteJSON`orgs/${org}` };
31
+ users = {
32
+ getByUsername: (username) => this.#fetchRouteJSON`users/${username}`,
33
+ find: (query) => this.#fetchRouteJSON`users/find/${query}`
34
+ };
35
+ repos = {
36
+ listForOrg: (org) => this.#fetchRouteJSON`orgs/${org}/repos`,
37
+ listForUser: (username) => this.#fetchRouteJSON`users/${username}/repos`,
38
+ get: (owner, repo) => this.#fetchRouteJSON`repos/${owner}/${repo}`,
39
+ listBranches: (owner, repo) => this.#fetchRouteJSON`repos/${owner}/${repo}/branches`,
40
+ getLatestRelease: (owner, repo) => this.#fetchRouteJSON`repos/${owner}/${repo}/releases/latest`,
41
+ listReleases: (owner, repo) => this.#fetchRouteJSON`repos/${owner}/${repo}/releases`,
42
+ listContributors: (owner, repo) => this.#fetchRouteJSON`repos/${owner}/${repo}/contributors`
43
+ };
44
+ };
45
+ //#endregion
46
+ export { Ungh as default };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@jcbhmr/ungh",
3
+ "version": "1.0.0",
4
+ "description": "🐙 ungh.cc API client for JavaScript",
5
+ "homepage": "https://npmx.dev/package-docs/@jcbhmr/ungh",
6
+ "bugs": {
7
+ "url": "https://github.com/jcbhmr/ungh/issues"
8
+ },
9
+ "license": "MIT",
10
+ "author": "Jacob Hummer <jcbhmr@outlook.com>",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/jcbhmr/ungh.git"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "type": "module",
19
+ "exports": {
20
+ ".": "./dist/index.mjs",
21
+ "./package.json": "./package.json"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^26.1.0",
28
+ "@typescript/native-preview": "7.0.0-dev.20260509.2",
29
+ "bumpp": "^11.1.0",
30
+ "typescript": "^6.0.3",
31
+ "vite-plus": "^0.2.3"
32
+ },
33
+ "devEngines": {
34
+ "packageManager": {
35
+ "name": "pnpm",
36
+ "version": "11.9.0",
37
+ "onFail": "download"
38
+ }
39
+ },
40
+ "scripts": {
41
+ "build": "vp pack",
42
+ "dev": "vp pack --watch",
43
+ "test": "vp test",
44
+ "check": "vp check"
45
+ }
46
+ }