mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Merge pull request #147 from jilleJr/feature/github-ee
Added GitHub Enterprise support
This commit is contained in:
commit
55c08c1dc0
4 changed files with 16 additions and 7 deletions
|
|
@ -11,13 +11,17 @@
|
|||
Create `.env` file to project root directory, and write your GitHub token to the `.env` file.
|
||||
Please select the authority of `repo` when creating token.
|
||||
|
||||
```
|
||||
```properties
|
||||
GITHUB_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
# if using GitHub Enterprise:
|
||||
# (this env var defaults to https://api.github.com/graphql)
|
||||
GITHUB_API=https://github.example.com/api/graphql
|
||||
```
|
||||
|
||||
Run local server.
|
||||
|
||||
```
|
||||
```sh
|
||||
deno run --allow-net --allow-read --allow-env debug.ts
|
||||
```
|
||||
|
||||
|
|
@ -33,6 +37,6 @@ Read the [.editorconfig](./.editorconfig)
|
|||
|
||||
If you want to contribute to my project, you should check the lint with the following command.
|
||||
|
||||
```
|
||||
```sh
|
||||
deno lint --unstable
|
||||
```
|
||||
```
|
||||
|
|
|
|||
3
index.ts
3
index.ts
|
|
@ -5,7 +5,8 @@ import { COLORS, Theme } from "./src/theme.ts";
|
|||
import { Error400, Error404 } from "./src/error_page.ts";
|
||||
import "https://deno.land/x/dotenv@v0.5.0/load.ts";
|
||||
|
||||
const client = new GithubAPIClient();
|
||||
const apiEndpoint = Deno.env.get("GITHUB_API") || CONSTANTS.DEFAULT_GITHUB_API;
|
||||
const client = new GithubAPIClient(apiEndpoint);
|
||||
|
||||
export default async (req: Request) => {
|
||||
const params = parseParams(req);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { soxa } from "../deps.ts";
|
||||
import { UserInfo } from "./user_info.ts";
|
||||
import { CONSTANTS } from "./utils.ts";
|
||||
import type {
|
||||
GitHubUserActivity,
|
||||
GitHubUserIssue,
|
||||
|
|
@ -8,7 +9,9 @@ import type {
|
|||
} from "./user_info.ts";
|
||||
|
||||
export class GithubAPIClient {
|
||||
constructor() {
|
||||
constructor(
|
||||
private apiEndpoint: string = CONSTANTS.DEFAULT_GITHUB_API,
|
||||
) {
|
||||
}
|
||||
async requestUserInfo(
|
||||
token: string | undefined,
|
||||
|
|
@ -114,7 +117,7 @@ export class GithubAPIClient {
|
|||
) {
|
||||
const variables = { username: username };
|
||||
const response = await soxa.post(
|
||||
"https://api.github.com/graphql",
|
||||
this.apiEndpoint,
|
||||
{},
|
||||
{
|
||||
data: { query: query, variables },
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ export const CONSTANTS = {
|
|||
DEFAULT_MARGIN_H: 0,
|
||||
DEFAULT_NO_BACKGROUND: false,
|
||||
DEFAULT_NO_FRAME: false,
|
||||
DEFAULT_GITHUB_API: "https://api.github.com/graphql",
|
||||
};
|
||||
|
||||
export enum RANK {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue