Skip to content

Commit

Permalink
feat: redirect GET / to GET /stats (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m authored Dec 11, 2020
1 parent 4c981ac commit 76406cc
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
19 changes: 18 additions & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,22 @@ const { createNodeMiddleware, createProbot } = require("probot");

const app = require("../");
const probot = createProbot();
const middleware = createNodeMiddleware(app, { probot });

module.exports = createNodeMiddleware(app, { probot });
/**
* Redirect `GET /` to `/stats`, pass `POST /` to Probot's middleware
*
* @param {import('@vercel/node').NowRequest} request
* @param {import('@vercel/node').NowResponse} response
*/
module.exports = (request, response) => {
if (request.method !== "POST") {
response.writeHead(302, {
Location: "/stats",
});
response.end();
return;
}

middleware(request, response);
};
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"devDependencies": {
"@sinonjs/fake-timers": "^6.0.1",
"@vercel/node": "^1.8.5",
"lodash.clonedeep": "^4.5.0",
"nock": "^13.0.5",
"prettier": "^2.2.1",
Expand Down
26 changes: 26 additions & 0 deletions public/stats/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WIP Usage Statistics</title>
<style>
html,
body,
iframe {
height: 100%;
margin: 0;
padding: 0;
border: 0;
width: 100%;
}
</style>
</head>
<body>
<iframe
src="https://datastudio.google.com/embed/reporting/194c8705-405b-4f1e-aed7-3889d76dab19/page/FlpsB"
frameborder="0"
allowfullscreen
></iframe>
</body>
</html>

1 comment on commit 76406cc

@vercel
Copy link

@vercel vercel bot commented on 76406cc Dec 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.