🚀 github user contribution api for dev
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -69,6 +69,8 @@ jobs:
|
|||||||
- uses: bahmutov/npm-install@v1.4.3
|
- uses: bahmutov/npm-install@v1.4.3
|
||||||
|
|
||||||
- run: yarn build:demo
|
- run: yarn build:demo
|
||||||
|
env:
|
||||||
|
GITHUB_USER_CONTRIBUTION_API_ENDPOINT: https://snk-one.vercel.app/api/github-user-contribution/
|
||||||
|
|
||||||
- uses: crazy-max/ghaction-github-pages@v2.1.3
|
- uses: crazy-max/ghaction-github-pages@v2.1.3
|
||||||
if: success() && github.ref == 'refs/heads/master'
|
if: success() && github.ref == 'refs/heads/master'
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ const createViewer = ({
|
|||||||
|
|
||||||
const onSubmit = async (userName: string) => {
|
const onSubmit = async (userName: string) => {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://snk-one.vercel.app/api/github-user-contribution/${userName}`
|
process.env.GITHUB_USER_CONTRIBUTION_API_ENDPOINT + userName
|
||||||
);
|
);
|
||||||
const { cells, colorScheme } = (await res.json()) as Res;
|
const { cells, colorScheme } = (await res.json()) as Res;
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,20 @@ import HtmlWebpackPlugin from "html-webpack-plugin";
|
|||||||
|
|
||||||
import type { Configuration as WebpackConfiguration } from "webpack";
|
import type { Configuration as WebpackConfiguration } from "webpack";
|
||||||
import type { Configuration as WebpackDevServerConfiguration } from "webpack-dev-server";
|
import type { Configuration as WebpackDevServerConfiguration } from "webpack-dev-server";
|
||||||
|
import webpack from "webpack";
|
||||||
|
import { getGithubUserContribution } from "@snk/github-user-contribution";
|
||||||
|
|
||||||
const demos: string[] = require("./demo.json");
|
const demos: string[] = require("./demo.json");
|
||||||
|
|
||||||
const webpackDevServerConfiguration: WebpackDevServerConfiguration = {
|
const webpackDevServerConfiguration: WebpackDevServerConfiguration = {
|
||||||
open: true,
|
open: true,
|
||||||
openPage: demos[1] + ".html",
|
openPage: demos[1] + ".html",
|
||||||
|
after: (app) => {
|
||||||
|
app.get("/api/github-user-contribution/:userName", async (req, res) => {
|
||||||
|
const userName: string = req.params.userName;
|
||||||
|
res.send(await getGithubUserContribution(userName));
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const webpackConfiguration: WebpackConfiguration = {
|
const webpackConfiguration: WebpackConfiguration = {
|
||||||
@@ -52,6 +60,11 @@ const webpackConfiguration: WebpackConfiguration = {
|
|||||||
filename: `index.html`,
|
filename: `index.html`,
|
||||||
chunks: [demos[0]],
|
chunks: [demos[0]],
|
||||||
}),
|
}),
|
||||||
|
new webpack.EnvironmentPlugin({
|
||||||
|
GITHUB_USER_CONTRIBUTION_API_ENDPOINT:
|
||||||
|
process.env.GITHUB_USER_CONTRIBUTION_API_ENDPOINT ??
|
||||||
|
"/api/github-user-contribution/",
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
devtool: false,
|
devtool: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user