🚀 github user contribution api for dev

This commit is contained in:
platane
2020-11-30 17:56:34 +01:00
parent 15fbf4bff6
commit 55758d606c
3 changed files with 16 additions and 1 deletions

View File

@@ -69,6 +69,8 @@ jobs:
- uses: bahmutov/npm-install@v1.4.3
- 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
if: success() && github.ref == 'refs/heads/master'

View File

@@ -190,7 +190,7 @@ const createViewer = ({
const onSubmit = async (userName: string) => {
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;

View File

@@ -3,12 +3,20 @@ import HtmlWebpackPlugin from "html-webpack-plugin";
import type { Configuration as WebpackConfiguration } from "webpack";
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 webpackDevServerConfiguration: WebpackDevServerConfiguration = {
open: true,
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 = {
@@ -52,6 +60,11 @@ const webpackConfiguration: WebpackConfiguration = {
filename: `index.html`,
chunks: [demos[0]],
}),
new webpack.EnvironmentPlugin({
GITHUB_USER_CONTRIBUTION_API_ENDPOINT:
process.env.GITHUB_USER_CONTRIBUTION_API_ENDPOINT ??
"/api/github-user-contribution/",
}),
],
devtool: false,