mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Added GITHUB_API env var
This commit is contained in:
parent
0d1525995c
commit
cb9b077fca
3 changed files with 8 additions and 3 deletions
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