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 {soxa} from "../deps.ts";
|
||||||
import "https://deno.land/x/dotenv@v0.5.0/load.ts";
|
|
||||||
|
|
||||||
class UserInfo {
|
class UserInfo {
|
||||||
constructor(
|
constructor(
|
||||||
public totalCommits: Number,
|
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",
|
"https://api.github.com/graphql",
|
||||||
|
{},
|
||||||
{
|
{
|
||||||
json: { query: query, variables },
|
data: { query: query, variables },
|
||||||
headers: { Authorization: `bearer ${token}` },
|
headers: { Authorization: `bearer ${token}` },
|
||||||
},
|
},
|
||||||
).json();
|
);
|
||||||
const totalCommits = response.data.user.contributionsCollection.restrictedContributionsCount + response.data.user.contributionsCollection.totalCommitContributions;
|
const userData = response.data.data.user;
|
||||||
const totalStargazers = response.data.user.repositories.nodes.reduce((prev: Number, node: any) => {
|
const totalCommits = userData.contributionsCollection.restrictedContributionsCount + userData.contributionsCollection.totalCommitContributions;
|
||||||
|
const totalStargazers = userData.repositories.nodes.reduce((prev: Number, node: any) => {
|
||||||
return prev + node.stargazers.totalCount;
|
return prev + node.stargazers.totalCount;
|
||||||
}, 0);
|
}, 0);
|
||||||
const userInfo = new UserInfo(
|
const userInfo = new UserInfo(
|
||||||
totalCommits,
|
totalCommits,
|
||||||
response.data.user.followers.totalCount,
|
userData.followers.totalCount,
|
||||||
response.data.user.issues.totalCount,
|
userData.issues.totalCount,
|
||||||
response.data.user.pullRequests.totalCount,
|
userData.pullRequests.totalCount,
|
||||||
totalStargazers,
|
totalStargazers,
|
||||||
response.data.user.repositories.totalCount,
|
userData.repositories.totalCount,
|
||||||
response.data.user.repositoriesContributedTo.totalCount,
|
userData.repositoriesContributedTo.totalCount,
|
||||||
)
|
)
|
||||||
return userInfo;
|
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