Remove Netlify, make an API server
This commit is contained in:
parent
0ea59d4bd0
commit
ec6cb4b355
73 changed files with 2238 additions and 334 deletions
25
api/coding_github.ts
Normal file
25
api/coding_github.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import {Octokit} from "@octokit/rest";
|
||||
import {type GithubInfo} from "#Infos/Coding/GitHub.tsx";
|
||||
import type { Handler } from "..";
|
||||
|
||||
export const coding_github: Handler = async () => {
|
||||
const octokit = new Octokit({auth: process.env["API_GITHUB"]});
|
||||
const github = await octokit.rest.activity.listEventsForAuthenticatedUser({username: "TTTaevas"});
|
||||
|
||||
const publicPush = github.data.find((e) => (e.type === "PushEvent" || e.type === "PullRequestEvent") && e.public);
|
||||
const privatePush = github.data.find((e) => (e.type === "PushEvent" || e.type === "PullRequestEvent") && !e.public);
|
||||
|
||||
const info: GithubInfo = {
|
||||
public: publicPush ? {
|
||||
repo: publicPush.repo.name,
|
||||
date: publicPush.created_at ? publicPush.created_at.substring(0, publicPush.created_at.indexOf("T")) : "",
|
||||
} : undefined,
|
||||
private: privatePush ? {
|
||||
date: privatePush.created_at ? privatePush.created_at.substring(0, privatePush.created_at.indexOf("T")) : "",
|
||||
} : undefined,
|
||||
};
|
||||
|
||||
return new Response(new Blob([JSON.stringify(info)], {
|
||||
type: "application/json",
|
||||
}), {status: 200});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue