diff --git a/api/index.js b/api/index.js index bca8d4266..4042f14b5 100644 --- a/api/index.js +++ b/api/index.js @@ -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); +}; diff --git a/package-lock.json b/package-lock.json index 4022de4d4..c89e451dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -867,6 +867,38 @@ "boxen": "^4.2.0" } }, + "@vercel/node": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/@vercel/node/-/node-1.8.5.tgz", + "integrity": "sha512-1iw7FSR8Oau6vZB1MWfBnA5q2a/IqRHiSZSbt8lz0dyTF599q8pc5GcSv/TvmrYaEGzh3+N0S4cbmuMCqVlwJg==", + "dev": true, + "requires": { + "@types/node": "*", + "ts-node": "8.9.1", + "typescript": "3.9.3" + }, + "dependencies": { + "ts-node": { + "version": "8.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.9.1.tgz", + "integrity": "sha512-yrq6ODsxEFTLz0R3BX2myf0WBCSQh9A+py8PBo1dCzWIOcvisbyH6akNKqDHMgXePF2kir5mm5JXJTH3OUJYOQ==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + } + }, + "typescript": { + "version": "3.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", + "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==", + "dev": true + } + } + }, "JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", diff --git a/package.json b/package.json index 8eb7b08da..f8785a0e2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/public/stats/index.html b/public/stats/index.html new file mode 100644 index 000000000..abc22eb8f --- /dev/null +++ b/public/stats/index.html @@ -0,0 +1,26 @@ + + + + + + WIP Usage Statistics + + + + + +