├── .env.sample
├── .gitignore
├── Caddyfile
├── README.md
├── api
├── .gitignore
├── Dockerfile
├── config
│ └── default.json
├── index.js
├── package-lock.json
└── package.json
├── dashboard.json
├── docker-compose.yml
├── start.sh
└── web
├── .dockerignore
├── .gitignore
├── Dockerfile
├── README.md
├── nginx.conf
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
└── src
├── App.css
├── App.js
├── App.test.js
├── index.css
├── index.js
├── logo.svg
└── serviceWorker.js
/.env.sample:
--------------------------------------------------------------------------------
1 | INFLUXDB_USER_PASSWORD=##put-a-secure-password##
2 | GF_SECURITY_ADMIN_PASSWORD=##put-a-secure-password##
3 | CADDY_EMAIL=email@domain.com
4 | GF_SERVER_ROOT_URL=##root-url-of-grafana##
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .env
2 | /influxdb-data
3 | /grafana-data
4 | /.caddy
5 | /log
6 | .idea
7 | *.iml
8 |
--------------------------------------------------------------------------------
/Caddyfile:
--------------------------------------------------------------------------------
1 | contributions.hacktoberfest.thecasualcoder.in
2 | tls {$CADDY_EMAIL}
3 |
4 | ext .html # Clean URLs
5 | errors error.log { # Error log
6 | 404 error-404.html # Custom error page
7 | }
8 |
9 | proxy /leaderboard http://grafana:3000 {
10 | fail_timeout 5s
11 | transparent
12 | without /leaderboard
13 | }
14 |
15 | proxy /api http://api:3000 {
16 | fail_timeout 5s
17 | transparent
18 | }
19 |
20 | proxy / http://web {
21 | fail_timeout 5s
22 | transparent
23 | }
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Hacktoberfest Monitor
2 |
3 | A dashboard for tracking hactoberfest PR contributions.
4 |
5 | ## Setup
6 |
7 | 1. Setup grafana and influxDB
8 |
9 | ```bash
10 | ## Setup necessary passwords in .env file
11 | $ cp .env.sample .env
12 |
13 | ## Startup docker-compose
14 | $ docker-compose up -d
15 | ```
16 |
17 | 2. Add influx as Grafana datasource. Visit http://localhost:3000 and add datasource with InfluxDB URL http://influxdb:8086
--------------------------------------------------------------------------------
/api/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/api/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:10.16.3
2 |
3 | ENV NODE_ENV production
4 | ENV APP_DIR /opt/app
5 | WORKDIR ${APP_DIR}
6 |
7 | ADD package.json package-lock.json ./
8 | RUN npm install --production
9 | ADD . ./
10 |
11 | EXPOSE 3000
12 |
13 | CMD ["npm", "start"]
14 |
--------------------------------------------------------------------------------
/api/config/default.json:
--------------------------------------------------------------------------------
1 | {
2 | "app": {
3 | "port": 3000
4 | },
5 | "hosts":["github.com","gitlab.com"]
6 | }
7 |
--------------------------------------------------------------------------------
/api/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const bodyParser = require('body-parser');
3 | const rateLimit = require("express-rate-limit");
4 | const axios = require('axios');
5 | const config = require('config')
6 | const app = express();
7 | const port = config.app.port;
8 | const Influx = require('influx');
9 |
10 | const limiter = rateLimit({
11 | windowMs: 1 * 60 * 1000, // 15 minutes
12 | max: 60 // limit each IP to 100 requests per windowMs
13 | });
14 |
15 | app.use(limiter);
16 | app.use(bodyParser.json());
17 |
18 | const dbProtocol = process.env.DB_PROTOCOL || "http";
19 | const dbHost = process.env.DB_HOST || "influxdb";
20 | const dbPort = process.env.DB_PORT || "8086";
21 | const dbUrl = `${dbHost}://${dbHost}:${dbPort}`
22 | const influx = new Influx.InfluxDB({
23 | protocol: dbProtocol,
24 | host: dbHost,
25 | port: dbPort,
26 | database: 'hacktober_metrics'
27 | })
28 |
29 | app.get('/ping', (req, res) => res.json({ "message": "pong" }));
30 |
31 | app.post('/api/pr', async (req, res) => {
32 | console.log(req.body);
33 | const {pr_link: prLink, language} = req.body;
34 |
35 | if (!prLink || !language) {
36 | res.status(400).json({ "message": "wrong data" });
37 | return
38 | }
39 |
40 | try {
41 | const prUrl = new URL(prLink);
42 | console.log(config.hosts)
43 | if (!config.hosts.includes(prUrl.host)) {
44 | console.log(prUrl.host + " not allowed");
45 | throw Error(prUrl.host + " not allowed");
46 | }
47 |
48 | await axios({
49 | method: 'head',
50 | url: prLink
51 | })
52 | } catch (e) {
53 | console.log(e);
54 | res.status(400).json({ "message": "wrong PR URL" });
55 | return;
56 | }
57 |
58 | try {
59 | let response = await influx.query(`select * from pull_request where pr_link = ${Influx.escape.stringLit(prLink)}`)
60 | if (response != undefined && response.length > 0) {
61 | return res.status(409).json({ "message": "This PR already added" });
62 | }
63 | } catch (e) {
64 | console.log(e);
65 | return res.status(500).json({ "message": "Internal error" });
66 | }
67 |
68 | const body = `pull_request,pr_link=${prLink.trim().replace(/ +/g, "-")},language=${language.trim().replace(/ +/g, "-")} value=1`;
69 |
70 | const url = `${dbUrl}/write?db=hacktober_metrics`;
71 | console.log(`Sending request to: ${url}`);
72 | try {
73 | await axios({
74 | method: 'post',
75 | url,
76 | data: body,
77 | });
78 | res.sendStatus(204)
79 | } catch (e) {
80 | res.sendStatus(500)
81 | }
82 | });
83 |
84 | app.listen(port, () => console.log(`Example app listening on port ${port}!`));
85 |
--------------------------------------------------------------------------------
/api/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "api",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "accepts": {
8 | "version": "1.3.7",
9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
10 | "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
11 | "requires": {
12 | "mime-types": "~2.1.24",
13 | "negotiator": "0.6.2"
14 | }
15 | },
16 | "array-flatten": {
17 | "version": "1.1.1",
18 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
19 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
20 | },
21 | "axios": {
22 | "version": "0.21.1",
23 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
24 | "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
25 | "requires": {
26 | "follow-redirects": "^1.10.0"
27 | }
28 | },
29 | "body-parser": {
30 | "version": "1.19.0",
31 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
32 | "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
33 | "requires": {
34 | "bytes": "3.1.0",
35 | "content-type": "~1.0.4",
36 | "debug": "2.6.9",
37 | "depd": "~1.1.2",
38 | "http-errors": "1.7.2",
39 | "iconv-lite": "0.4.24",
40 | "on-finished": "~2.3.0",
41 | "qs": "6.7.0",
42 | "raw-body": "2.4.0",
43 | "type-is": "~1.6.17"
44 | }
45 | },
46 | "bytes": {
47 | "version": "3.1.0",
48 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
49 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
50 | },
51 | "config": {
52 | "version": "3.3.2",
53 | "resolved": "https://registry.npmjs.org/config/-/config-3.3.2.tgz",
54 | "integrity": "sha512-NlGfBn2565YA44Irn7GV5KHlIGC3KJbf0062/zW5ddP9VXIuRj0m7HVyFAWvMZvaHPEglyGfwmevGz3KosIpCg==",
55 | "requires": {
56 | "json5": "^2.1.1"
57 | }
58 | },
59 | "content-disposition": {
60 | "version": "0.5.3",
61 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
62 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
63 | "requires": {
64 | "safe-buffer": "5.1.2"
65 | }
66 | },
67 | "content-type": {
68 | "version": "1.0.4",
69 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
70 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
71 | },
72 | "cookie": {
73 | "version": "0.4.0",
74 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
75 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
76 | },
77 | "cookie-signature": {
78 | "version": "1.0.6",
79 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
80 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
81 | },
82 | "debug": {
83 | "version": "2.6.9",
84 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
85 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
86 | "requires": {
87 | "ms": "2.0.0"
88 | }
89 | },
90 | "depd": {
91 | "version": "1.1.2",
92 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
93 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
94 | },
95 | "destroy": {
96 | "version": "1.0.4",
97 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
98 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
99 | },
100 | "ee-first": {
101 | "version": "1.1.1",
102 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
103 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
104 | },
105 | "encodeurl": {
106 | "version": "1.0.2",
107 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
108 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
109 | },
110 | "escape-html": {
111 | "version": "1.0.3",
112 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
113 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
114 | },
115 | "etag": {
116 | "version": "1.8.1",
117 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
118 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
119 | },
120 | "express": {
121 | "version": "4.17.1",
122 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
123 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
124 | "requires": {
125 | "accepts": "~1.3.7",
126 | "array-flatten": "1.1.1",
127 | "body-parser": "1.19.0",
128 | "content-disposition": "0.5.3",
129 | "content-type": "~1.0.4",
130 | "cookie": "0.4.0",
131 | "cookie-signature": "1.0.6",
132 | "debug": "2.6.9",
133 | "depd": "~1.1.2",
134 | "encodeurl": "~1.0.2",
135 | "escape-html": "~1.0.3",
136 | "etag": "~1.8.1",
137 | "finalhandler": "~1.1.2",
138 | "fresh": "0.5.2",
139 | "merge-descriptors": "1.0.1",
140 | "methods": "~1.1.2",
141 | "on-finished": "~2.3.0",
142 | "parseurl": "~1.3.3",
143 | "path-to-regexp": "0.1.7",
144 | "proxy-addr": "~2.0.5",
145 | "qs": "6.7.0",
146 | "range-parser": "~1.2.1",
147 | "safe-buffer": "5.1.2",
148 | "send": "0.17.1",
149 | "serve-static": "1.14.1",
150 | "setprototypeof": "1.1.1",
151 | "statuses": "~1.5.0",
152 | "type-is": "~1.6.18",
153 | "utils-merge": "1.0.1",
154 | "vary": "~1.1.2"
155 | }
156 | },
157 | "express-rate-limit": {
158 | "version": "5.0.0",
159 | "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.0.0.tgz",
160 | "integrity": "sha512-dhT57wqxfqmkOi4HM7NuT4Gd7gbUgSK2ocG27Y6lwm8lbOAw9XQfeANawGq8wLDtlGPO1ZgDj0HmKsykTxfFAg=="
161 | },
162 | "finalhandler": {
163 | "version": "1.1.2",
164 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
165 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
166 | "requires": {
167 | "debug": "2.6.9",
168 | "encodeurl": "~1.0.2",
169 | "escape-html": "~1.0.3",
170 | "on-finished": "~2.3.0",
171 | "parseurl": "~1.3.3",
172 | "statuses": "~1.5.0",
173 | "unpipe": "~1.0.0"
174 | }
175 | },
176 | "follow-redirects": {
177 | "version": "1.13.1",
178 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz",
179 | "integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg=="
180 | },
181 | "forwarded": {
182 | "version": "0.1.2",
183 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
184 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
185 | },
186 | "fresh": {
187 | "version": "0.5.2",
188 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
189 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
190 | },
191 | "http-errors": {
192 | "version": "1.7.2",
193 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
194 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
195 | "requires": {
196 | "depd": "~1.1.2",
197 | "inherits": "2.0.3",
198 | "setprototypeof": "1.1.1",
199 | "statuses": ">= 1.5.0 < 2",
200 | "toidentifier": "1.0.0"
201 | }
202 | },
203 | "iconv-lite": {
204 | "version": "0.4.24",
205 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
206 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
207 | "requires": {
208 | "safer-buffer": ">= 2.1.2 < 3"
209 | }
210 | },
211 | "influx": {
212 | "version": "5.6.3",
213 | "resolved": "https://registry.npmjs.org/influx/-/influx-5.6.3.tgz",
214 | "integrity": "sha512-j2biV776HXb2IbIcp2G24w50IqIWENDnKitm0Vj54vlpw9EfGzY7x7ndCRZSGzzm4fyDLSDQ+/cypZQpuDQxyA=="
215 | },
216 | "inherits": {
217 | "version": "2.0.3",
218 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
219 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
220 | },
221 | "ipaddr.js": {
222 | "version": "1.9.0",
223 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
224 | "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA=="
225 | },
226 | "json5": {
227 | "version": "2.1.3",
228 | "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz",
229 | "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==",
230 | "requires": {
231 | "minimist": "^1.2.5"
232 | }
233 | },
234 | "media-typer": {
235 | "version": "0.3.0",
236 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
237 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
238 | },
239 | "merge-descriptors": {
240 | "version": "1.0.1",
241 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
242 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
243 | },
244 | "methods": {
245 | "version": "1.1.2",
246 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
247 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
248 | },
249 | "mime": {
250 | "version": "1.6.0",
251 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
252 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
253 | },
254 | "mime-db": {
255 | "version": "1.40.0",
256 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz",
257 | "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
258 | },
259 | "mime-types": {
260 | "version": "2.1.24",
261 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz",
262 | "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
263 | "requires": {
264 | "mime-db": "1.40.0"
265 | }
266 | },
267 | "minimist": {
268 | "version": "1.2.5",
269 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
270 | "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
271 | },
272 | "ms": {
273 | "version": "2.0.0",
274 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
275 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
276 | },
277 | "negotiator": {
278 | "version": "0.6.2",
279 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
280 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
281 | },
282 | "on-finished": {
283 | "version": "2.3.0",
284 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
285 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
286 | "requires": {
287 | "ee-first": "1.1.1"
288 | }
289 | },
290 | "parseurl": {
291 | "version": "1.3.3",
292 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
293 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
294 | },
295 | "path-to-regexp": {
296 | "version": "0.1.7",
297 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
298 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
299 | },
300 | "proxy-addr": {
301 | "version": "2.0.5",
302 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz",
303 | "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==",
304 | "requires": {
305 | "forwarded": "~0.1.2",
306 | "ipaddr.js": "1.9.0"
307 | }
308 | },
309 | "qs": {
310 | "version": "6.7.0",
311 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
312 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
313 | },
314 | "range-parser": {
315 | "version": "1.2.1",
316 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
317 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
318 | },
319 | "raw-body": {
320 | "version": "2.4.0",
321 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
322 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
323 | "requires": {
324 | "bytes": "3.1.0",
325 | "http-errors": "1.7.2",
326 | "iconv-lite": "0.4.24",
327 | "unpipe": "1.0.0"
328 | }
329 | },
330 | "safe-buffer": {
331 | "version": "5.1.2",
332 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
333 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
334 | },
335 | "safer-buffer": {
336 | "version": "2.1.2",
337 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
338 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
339 | },
340 | "send": {
341 | "version": "0.17.1",
342 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
343 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
344 | "requires": {
345 | "debug": "2.6.9",
346 | "depd": "~1.1.2",
347 | "destroy": "~1.0.4",
348 | "encodeurl": "~1.0.2",
349 | "escape-html": "~1.0.3",
350 | "etag": "~1.8.1",
351 | "fresh": "0.5.2",
352 | "http-errors": "~1.7.2",
353 | "mime": "1.6.0",
354 | "ms": "2.1.1",
355 | "on-finished": "~2.3.0",
356 | "range-parser": "~1.2.1",
357 | "statuses": "~1.5.0"
358 | },
359 | "dependencies": {
360 | "ms": {
361 | "version": "2.1.1",
362 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
363 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
364 | }
365 | }
366 | },
367 | "serve-static": {
368 | "version": "1.14.1",
369 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
370 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
371 | "requires": {
372 | "encodeurl": "~1.0.2",
373 | "escape-html": "~1.0.3",
374 | "parseurl": "~1.3.3",
375 | "send": "0.17.1"
376 | }
377 | },
378 | "setprototypeof": {
379 | "version": "1.1.1",
380 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
381 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
382 | },
383 | "statuses": {
384 | "version": "1.5.0",
385 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
386 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
387 | },
388 | "toidentifier": {
389 | "version": "1.0.0",
390 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
391 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
392 | },
393 | "type-is": {
394 | "version": "1.6.18",
395 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
396 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
397 | "requires": {
398 | "media-typer": "0.3.0",
399 | "mime-types": "~2.1.24"
400 | }
401 | },
402 | "unpipe": {
403 | "version": "1.0.0",
404 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
405 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
406 | },
407 | "utils-merge": {
408 | "version": "1.0.1",
409 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
410 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
411 | },
412 | "vary": {
413 | "version": "1.1.2",
414 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
415 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
416 | }
417 | }
418 | }
419 |
--------------------------------------------------------------------------------
/api/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "api",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node index.js",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "axios": "^0.21.1",
14 | "body-parser": "^1.19.0",
15 | "config": "^3.3.2",
16 | "express": "^4.17.1",
17 | "express-rate-limit": "^5.0.0",
18 | "influx": "^5.6.3"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/dashboard.json:
--------------------------------------------------------------------------------
1 | {
2 | "annotations": {
3 | "list": [
4 | {
5 | "builtIn": 1,
6 | "datasource": "-- Grafana --",
7 | "enable": true,
8 | "hide": true,
9 | "iconColor": "rgba(0, 211, 255, 1)",
10 | "name": "Annotations & Alerts",
11 | "type": "dashboard"
12 | }
13 | ]
14 | },
15 | "editable": true,
16 | "gnetId": null,
17 | "graphTooltip": 0,
18 | "id": 1,
19 | "links": [],
20 | "panels": [
21 | {
22 | "cacheTimeout": null,
23 | "datasource": "InfluxDB",
24 | "gridPos": {
25 | "h": 8,
26 | "w": 24,
27 | "x": 0,
28 | "y": 0
29 | },
30 | "id": 4,
31 | "links": [],
32 | "options": {
33 | "fieldOptions": {
34 | "calcs": [
35 | "sum"
36 | ],
37 | "defaults": {
38 | "mappings": [
39 | {
40 | "id": 0,
41 | "op": "=",
42 | "text": "N/A",
43 | "type": 1,
44 | "value": "null"
45 | }
46 | ],
47 | "max": 100,
48 | "min": 0,
49 | "nullValueMode": "connected",
50 | "thresholds": [
51 | {
52 | "color": "red",
53 | "value": null
54 | },
55 | {
56 | "color": "#EAB839",
57 | "value": 25
58 | },
59 | {
60 | "color": "semi-dark-green",
61 | "value": 50
62 | },
63 | {
64 | "color": "dark-green",
65 | "value": 75
66 | }
67 | ],
68 | "title": "PRs",
69 | "unit": "none"
70 | },
71 | "override": {},
72 | "values": false
73 | },
74 | "orientation": "horizontal",
75 | "showThresholdLabels": false,
76 | "showThresholdMarkers": true
77 | },
78 | "pluginVersion": "6.4.1",
79 | "targets": [
80 | {
81 | "groupBy": [
82 | {
83 | "params": [
84 | "$__interval"
85 | ],
86 | "type": "time"
87 | },
88 | {
89 | "params": [
90 | "null"
91 | ],
92 | "type": "fill"
93 | }
94 | ],
95 | "orderByTime": "ASC",
96 | "policy": "default",
97 | "query": "SELECT \"value\" FROM \"pull_request\"",
98 | "rawQuery": true,
99 | "refId": "A",
100 | "resultFormat": "time_series",
101 | "select": [
102 | [
103 | {
104 | "params": [
105 | "value"
106 | ],
107 | "type": "field"
108 | },
109 | {
110 | "params": [],
111 | "type": "mean"
112 | }
113 | ]
114 | ],
115 | "tags": []
116 | }
117 | ],
118 | "timeFrom": null,
119 | "timeShift": null,
120 | "title": "PRs for the day",
121 | "transparent": true,
122 | "type": "gauge"
123 | },
124 | {
125 | "aliasColors": {},
126 | "bars": false,
127 | "cacheTimeout": null,
128 | "dashLength": 10,
129 | "dashes": false,
130 | "datasource": "InfluxDB",
131 | "fill": 1,
132 | "fillGradient": 1,
133 | "gridPos": {
134 | "h": 9,
135 | "w": 24,
136 | "x": 0,
137 | "y": 8
138 | },
139 | "id": 2,
140 | "legend": {
141 | "alignAsTable": true,
142 | "avg": false,
143 | "current": false,
144 | "hideEmpty": false,
145 | "hideZero": false,
146 | "max": false,
147 | "min": false,
148 | "rightSide": true,
149 | "show": true,
150 | "sideWidth": null,
151 | "total": false,
152 | "values": false
153 | },
154 | "lines": true,
155 | "linewidth": 0,
156 | "links": [],
157 | "nullPointMode": "null as zero",
158 | "options": {
159 | "dataLinks": []
160 | },
161 | "percentage": false,
162 | "pluginVersion": "6.4.1",
163 | "pointradius": 5,
164 | "points": true,
165 | "renderer": "flot",
166 | "repeat": null,
167 | "seriesOverrides": [],
168 | "spaceLength": 10,
169 | "stack": false,
170 | "steppedLine": true,
171 | "targets": [
172 | {
173 | "alias": "$tag_language",
174 | "groupBy": [
175 | {
176 | "params": [
177 | "$__interval"
178 | ],
179 | "type": "time"
180 | },
181 | {
182 | "params": [
183 | "language"
184 | ],
185 | "type": "tag"
186 | },
187 | {
188 | "params": [
189 | "null"
190 | ],
191 | "type": "fill"
192 | }
193 | ],
194 | "orderByTime": "ASC",
195 | "policy": "default",
196 | "query": "SELECT \"value\" FROM \"pull_request\" WHERE $timeFilter GROUP BY \"language\"",
197 | "rawQuery": true,
198 | "refId": "A",
199 | "resultFormat": "time_series",
200 | "select": [
201 | [
202 | {
203 | "params": [
204 | "value"
205 | ],
206 | "type": "field"
207 | },
208 | {
209 | "params": [],
210 | "type": "mean"
211 | }
212 | ]
213 | ],
214 | "tags": []
215 | }
216 | ],
217 | "thresholds": [],
218 | "timeFrom": null,
219 | "timeRegions": [],
220 | "timeShift": null,
221 | "title": "Contributions Timeline",
222 | "tooltip": {
223 | "shared": true,
224 | "sort": 1,
225 | "value_type": "individual"
226 | },
227 | "transparent": true,
228 | "type": "graph",
229 | "xaxis": {
230 | "buckets": null,
231 | "mode": "time",
232 | "name": null,
233 | "show": true,
234 | "values": []
235 | },
236 | "yaxes": [
237 | {
238 | "format": "short",
239 | "label": null,
240 | "logBase": 1,
241 | "max": null,
242 | "min": null,
243 | "show": true
244 | },
245 | {
246 | "format": "short",
247 | "label": null,
248 | "logBase": 1,
249 | "max": null,
250 | "min": null,
251 | "show": true
252 | }
253 | ],
254 | "yaxis": {
255 | "align": false,
256 | "alignLevel": null
257 | }
258 | }
259 | ],
260 | "refresh": "5s",
261 | "schemaVersion": 20,
262 | "style": "dark",
263 | "tags": [],
264 | "templating": {
265 | "list": []
266 | },
267 | "time": {
268 | "from": "now/d",
269 | "to": "now"
270 | },
271 | "timepicker": {
272 | "refresh_intervals": [
273 | "5s",
274 | "10s",
275 | "30s",
276 | "1m",
277 | "5m",
278 | "15m",
279 | "30m",
280 | "1h",
281 | "2h",
282 | "1d"
283 | ]
284 | },
285 | "timezone": "",
286 | "title": "PR Contributions",
287 | "uid": "DITAG22Wk",
288 | "version": 8
289 | }
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.7"
2 | services:
3 | caddy:
4 | image: "abiosoft/caddy"
5 | volumes:
6 | - ./log:/srv
7 | - ./Caddyfile:/etc/Caddyfile
8 | - ./.caddy:/root/.caddy
9 | ports:
10 | - "80:80"
11 | - "443:443"
12 | environment:
13 | ACME_AGREE: "true"
14 | CADDY_EMAIL: "${CADDY_EMAIL}"
15 | influxdb:
16 | image: influxdb
17 | volumes:
18 | - "./influxdb-data:/var/lib/influxdb"
19 | environment:
20 | INFLUXDB_USER: "hacktober_collector"
21 | INFLUXDB_DB: "hacktober_metrics"
22 | INFLUXDB_USER_PASSWORD: "${INFLUXDB_USER_PASSWORD}"
23 | grafana:
24 | image: grafana/grafana
25 | environment:
26 | GF_SECURITY_ADMIN_PASSWORD: "${GF_SECURITY_ADMIN_PASSWORD}"
27 | GF_SERVER_ROOT_URL: "${GF_SERVER_ROOT_URL}"
28 | GF_AUTH_ANONYMOUS_ENABLED: "true"
29 | ports:
30 | - "3000:3000"
31 | volumes:
32 | - "./grafana-data:/var/lib/grafana"
33 | web:
34 | build:
35 | context: web/
36 | dockerfile: Dockerfile
37 | api:
38 | build:
39 | context: api/
40 | dockerfile: Dockerfile
41 |
--------------------------------------------------------------------------------
/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | mkdir -p influxdb-data grafana-data .caddy log
6 | docker-compose up -d
--------------------------------------------------------------------------------
/web/.dockerignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/web/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/web/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:10.16.3 as source
2 | WORKDIR /opt/app
3 | COPY ./package.json ./
4 | RUN npm install --production
5 | COPY . ./
6 | RUN npm run build
7 |
8 | FROM nginx:1.17.4
9 | WORKDIR /opt/app
10 | COPY --from=source /opt/app/build .
11 | COPY nginx.conf /etc/nginx/conf.d/default.conf
12 | CMD ["nginx", "-g", "daemon off;"]
13 |
--------------------------------------------------------------------------------
/web/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `npm start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `npm test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `npm run build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `npm run eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `npm run build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/web/nginx.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 80;
3 |
4 | location / {
5 | root /opt/app/;
6 | index index.html index.htm;
7 | }
8 | }
--------------------------------------------------------------------------------
/web/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "web",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "axios": "^0.21.1",
7 | "react": "^16.10.2",
8 | "react-alert": "^5.5.0",
9 | "react-alert-template-basic": "^1.0.0",
10 | "react-dom": "^16.10.2",
11 | "react-jsonschema-form": "^1.8.0",
12 | "react-scripts": "3.2.0",
13 | "react-transition-group": "^4.3.0"
14 | },
15 | "scripts": {
16 | "start": "react-scripts start",
17 | "build": "react-scripts build",
18 | "test": "react-scripts test",
19 | "eject": "react-scripts eject"
20 | },
21 | "eslintConfig": {
22 | "extends": "react-app"
23 | },
24 | "browserslist": {
25 | "production": [
26 | ">0.2%",
27 | "not dead",
28 | "not op_mini all"
29 | ],
30 | "development": [
31 | "last 1 chrome version",
32 | "last 1 firefox version",
33 | "last 1 safari version"
34 | ]
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/web/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thecasualcoder/hacktoberfest-monitor/e787c7dd999f92875fc440f9f4335ba2327ebefa/web/public/favicon.ico
--------------------------------------------------------------------------------
/web/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |