Skip to content

Commit 01fdbde

Browse files
committed
Readme update
1 parent 2b14ab4 commit 01fdbde

File tree

3 files changed

+100
-4
lines changed

3 files changed

+100
-4
lines changed

README.md

+96
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,98 @@
11
# ghrapi
2+
23
Github rest api Deno module
4+
I make it for my personel use, at this time it is not complete, but you can use it if you want.
5+
6+
## Usage
7+
8+
```ts
9+
import { Ghrapi } from "https://deno.land/x/ghrapi/mod.ts";
10+
const gh = new Ghrapi({
11+
entrypoint?: "your github api entrypoint", // by default is https://api.github.com
12+
token?: "your github token", // if you want to use private repo (you don't need to pass it if is a env var)
13+
orgs?: ["your orgs"], // if you want to use organisations repos
14+
me: "your github username"
15+
});
16+
```
17+
18+
## Methods
19+
20+
```ts
21+
// Get all own repos
22+
const repos = await gh.userRepos({}?: UserReposOptions);
23+
// Get all own repos from an user
24+
const repos = await gh.userRepos({
25+
username?: "username"
26+
}?: UserReposOptions);
27+
// Get all own repos from an organisation
28+
const repos = await gh.orgRepos({
29+
org?: "org name"
30+
}?: OrgReposOptions);
31+
```
32+
33+
## Types Definitions
34+
35+
```ts
36+
export type GithubApiOptions = {
37+
entrypoint?: string;
38+
token?: string;
39+
orgs?: string[];
40+
me: string;
41+
}
42+
43+
export type OrgReposOptions = {
44+
type?: "all" | "public" | "private" | "forks" | "sources" | "member" | "internal";
45+
sort?: "created" | "updated" | "pushed" | "full_name";
46+
direction?: "asc" | "desc";
47+
per_page?: number;
48+
page?: number;
49+
}
50+
51+
export type UserReposOptions = OrgReposOptions & {
52+
visibility?: "all" | "public" | "private",
53+
affiliation?: string,
54+
type?: "all" | "owner" | "public" | "private" | "member",
55+
since?: string,
56+
before?: string,
57+
}
58+
```
59+
60+
## Example
61+
62+
```ts
63+
import { Ghrapi } from "https://deno.land/x/ghrapi/mod.ts";
64+
const gh = new Ghrapi({
65+
token: "your github token", // if you want to use private repo (you don't need to pass it if is a env var)
66+
me: "your github username"
67+
});
68+
69+
const repos = await gh.userRepos({
70+
options: {
71+
type: "all",
72+
sort: "created",
73+
direction: "asc",
74+
per_page: 1,
75+
page: 1
76+
}
77+
});
78+
79+
console.log(repos);
80+
```
81+
82+
## TODO
83+
84+
- [ ] Add more stuff
85+
86+
## License
87+
88+
```text
89+
Apache License
90+
```
91+
92+
## Support
93+
94+
```text
95+
If you like my work, you can support me with a coffee
96+
```
97+
98+
[![Buy Me A Coffee](https://media.giphy.com/media/o7RZbs4KAA6tvM4H6j/giphy.gif)](https://www.buymeacoffee.com/mnlaugh)

mod.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type GithubApiOptions = {
1+
export type GhrapiOptions = {
22
entrypoint?: string;
33
token?: string;
44
orgs?: string[];

mod.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type {
22
OrgReposOptions,
33
UserReposOptions,
4-
GithubApiOptions,
4+
GhrapiOptions,
55
Repo,
66
} from "./mod.d.ts";
77

8-
export default class GithubApi {
8+
export default class Ghrapi {
99
ratelimitRemaining: number;
1010
rateLimitResetDate?: Date;
1111
entrypoint: string;
@@ -17,7 +17,7 @@ export default class GithubApi {
1717
token,
1818
orgs = [],
1919
me,
20-
}: GithubApiOptions) {
20+
}: GhrapiOptions) {
2121
this.ratelimitRemaining = 0;
2222
this.entrypoint = entrypoint;
2323
this.#token = token || Deno.env.get("GITHUB_TOKEN");

0 commit comments

Comments
 (0)