mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Add vercel.json
This commit is contained in:
parent
5a9cbef00b
commit
09d8f21989
6 changed files with 31 additions and 22 deletions
|
|
@ -1,8 +0,0 @@
|
|||
import { serve } from "./../deps.ts";
|
||||
import { GithubAPIClient } from './../src/github_api_client.ts';
|
||||
const client = new GithubAPIClient();
|
||||
await client.requestUserData("ryo-ma");
|
||||
const server = serve({ port: 8080 });
|
||||
for await (const req of server) {
|
||||
req.respond({ body: "<h1> TEST </h1>"});
|
||||
}
|
||||
3
deps.ts
3
deps.ts
|
|
@ -1 +1,2 @@
|
|||
export { serve } from "https://deno.land/std@0.65.0/http/server.ts";
|
||||
export { ServerRequest } from "https://deno.land/std@0.66.0/http/server.ts";
|
||||
export { soxa } from "https://deno.land/x/soxa@v1.3/mod.ts";
|
||||
9
index.ts
Normal file
9
index.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { ServerRequest } from "./deps.ts";
|
||||
import { GithubAPIClient } from "./src/github_api_client.ts";
|
||||
import "https://deno.land/x/dotenv@v0.5.0/load.ts";
|
||||
const client = new GithubAPIClient();
|
||||
|
||||
export default async (req: ServerRequest) => {
|
||||
const userInfo = await client.requestUserData("ryo-ma")
|
||||
req.respond({ body: `Hello, from Deno v${Deno.version.deno}!` + userInfo });
|
||||
};
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
import ky from "https://deno.land/x/ky/index.js";
|
||||
import "https://deno.land/x/dotenv@v0.5.0/load.ts";
|
||||
|
||||
import {soxa} from "../deps.ts";
|
||||
class UserInfo {
|
||||
constructor(
|
||||
public totalCommits: Number,
|
||||
|
|
@ -52,25 +50,27 @@ export class GithubAPIClient {
|
|||
}
|
||||
}
|
||||
`;
|
||||
const response = await ky.post(
|
||||
const response = await soxa.post(
|
||||
"https://api.github.com/graphql",
|
||||
{},
|
||||
{
|
||||
json: { query: query, variables },
|
||||
data: { query: query, variables },
|
||||
headers: { Authorization: `bearer ${token}` },
|
||||
},
|
||||
).json();
|
||||
const totalCommits = response.data.user.contributionsCollection.restrictedContributionsCount + response.data.user.contributionsCollection.totalCommitContributions;
|
||||
const totalStargazers = response.data.user.repositories.nodes.reduce((prev: Number, node: any) => {
|
||||
);
|
||||
const userData = response.data.data.user;
|
||||
const totalCommits = userData.contributionsCollection.restrictedContributionsCount + userData.contributionsCollection.totalCommitContributions;
|
||||
const totalStargazers = userData.repositories.nodes.reduce((prev: Number, node: any) => {
|
||||
return prev + node.stargazers.totalCount;
|
||||
}, 0);
|
||||
const userInfo = new UserInfo(
|
||||
totalCommits,
|
||||
response.data.user.followers.totalCount,
|
||||
response.data.user.issues.totalCount,
|
||||
response.data.user.pullRequests.totalCount,
|
||||
userData.followers.totalCount,
|
||||
userData.issues.totalCount,
|
||||
userData.pullRequests.totalCount,
|
||||
totalStargazers,
|
||||
response.data.user.repositories.totalCount,
|
||||
response.data.user.repositoriesContributedTo.totalCount,
|
||||
userData.repositories.totalCount,
|
||||
userData.repositoriesContributedTo.totalCount,
|
||||
)
|
||||
return userInfo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export const icons = "icons";
|
||||
6
vercel.json
Normal file
6
vercel.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"builds":[{
|
||||
"src": "**/index.ts",
|
||||
"use": "vercel-deno@0.6.4"}],
|
||||
"routes": [{ "src": "/.*", "dest": "/" }]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue