|
1 | 1 | # ghrapi
|
| 2 | + |
2 | 3 | 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 | +[](https://www.buymeacoffee.com/mnlaugh) |
0 commit comments