From e55e219191282d200853f56df4be7a3bc741e81b Mon Sep 17 00:00:00 2001 From: Michael Masterson Date: Wed, 10 Jan 2018 16:54:58 -0800 Subject: [PATCH 1/3] Github API communicating with server --- .gitignore | 3 +- client/package.json | 2 +- index.js | 17 --- package-lock.json | 44 +++++- package.json | 5 +- public/css/styles.css | 320 ------------------------------------------ server.js | 23 ++- views/index.html | 98 ------------- 8 files changed, 65 insertions(+), 447 deletions(-) delete mode 100644 index.js delete mode 100644 public/css/styles.css delete mode 100644 views/index.html diff --git a/.gitignore b/.gitignore index b512c09..1dcef2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.env \ No newline at end of file diff --git a/client/package.json b/client/package.json index e2fe5dd..8b5c463 100644 --- a/client/package.json +++ b/client/package.json @@ -14,4 +14,4 @@ "eject": "react-scripts eject" }, "proxy": "http://localhost:5000" -} \ No newline at end of file +} diff --git a/index.js b/index.js deleted file mode 100644 index b7c3fa9..0000000 --- a/index.js +++ /dev/null @@ -1,17 +0,0 @@ -const express = require('express') -const app = express() -const path = require('path') - -app.set('views', path.join(__dirname, 'views')) -app.use(express.static(path.join(__dirname, '/public'))) - - -app.get('/', (request, response) => { - response.sendFile(__dirname + '/views/index.html') -}) - -const port = process.env.PORT || 3000 - -app.listen(port, () => { - console.log(`App listening on port: ${port}`) -}) \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ce94aa5..d7e4354 100644 --- a/package-lock.json +++ b/package-lock.json @@ -398,6 +398,11 @@ "is-obj": "1.0.1" } }, + "dotenv": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz", + "integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=" + }, "duplexer": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", @@ -420,6 +425,19 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "requires": { + "iconv-lite": "0.4.19" + } + }, + "es6-promise": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.2.tgz", + "integrity": "sha512-LSas5vsuA6Q4nEdf9wokY5/AJYXry98i0IzXsv49rYsgDGDNDPbqAYR1Pe23iFxygfbGZNR/5VrHXBCh2BhvUQ==" + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -1763,8 +1781,7 @@ "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" }, "isarray": { "version": "1.0.0", @@ -1787,6 +1804,15 @@ "isarray": "1.0.0" } }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "requires": { + "node-fetch": "1.7.3", + "whatwg-fetch": "2.0.3" + } + }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -1927,6 +1953,15 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" }, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "requires": { + "encoding": "0.1.12", + "is-stream": "1.1.0" + } + }, "nodemon": { "version": "1.14.9", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.14.9.tgz", @@ -2536,6 +2571,11 @@ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, + "whatwg-fetch": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", + "integrity": "sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ=" + }, "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", diff --git a/package.json b/package.json index 4ff086a..0e5b6fd 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,11 @@ "homepage": "https://github.com/pporche87/queersintech#readme", "dependencies": { "concurrently": "^3.5.1", + "dotenv": "^4.0.0", + "es6-promise": "^4.2.2", "express": "^4.16.2", - "font-awesome": "^4.7.0" + "font-awesome": "^4.7.0", + "isomorphic-fetch": "^2.2.1" }, "devDependencies": { "nodemon": "^1.14.9" diff --git a/public/css/styles.css b/public/css/styles.css deleted file mode 100644 index 7dcf4cc..0000000 --- a/public/css/styles.css +++ /dev/null @@ -1,320 +0,0 @@ -/* * { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -html { - font: normal 16px sans-serif; - color: #555; -} - -ul, -nav { - list-style: none; -} - -a { - text-decoration: none; - opacity: 0.75; - color: #fff; -} - -a.btn { - border-radius: 4px; - text-transform: uppercase; - font-weight: bold; - text-align: center; - background-color: #3f51b5; - opacity: 1; -} - -section { - display: flex; - flex-direction: column; - align-items: center; - padding: 100px 80px; -} - -section:not(.hero):nth-child(even) { - background-color: #f5f5f5; -} - -.grid { - width: 100%; - display: flex; - flex-wrap: wrap; - justify-content: center; -} - -hr { - width: 250px; - height: 3px; - background-color: #3f51b5; - border: 0; - margin-bottom: 50px; -} - -section h3.title { - text-transform: capitalize; - font: bold 32px "Open Sans", sans-serif; - margin-bottom: 30px; - text-align: center; -} - -section p { - max-width: 775px; - line-height: 2; - padding: 0 20px; - margin-bottom: 30px; - text-align: center; -} - -@media (max-width: 800px) { - section { - padding: 50px 20px; - } -} */ - -/* HEADER STYLES */ -/* -header { - position: absolute; - width: 100%; - display: flex; - justify-content: space-between; - align-items: center; - padding: 35px 100px 0; - animation: 0s fadein 0.5s forwards; - opacity: 0; - z-index: 1; -} - -@keyframes fadein { - 100% { - opacity: 1; - } -} - -header h2 { - font-family: "Quicksand", sans-serif; -} - -header nav { - display: flex; - margin-right: -15px; -} - -header nav li { - margin: 0 15px; -} - -@media (max-width: 800px) { - header { - padding: 20px 50px; - flex-direction: column; - } - header h2 { - margin-bottom: 15px; - } -} */ - -/* HERO STYLES */ - -/* .hero { - position: relative; - justify-content: center; - text-align: center; - min-height: 100vh; - color: #fff; -} - -.hero .background-image { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-size: cover; - z-index: -1; - background-color: #000; - opacity: 0; - animation: 1s backfadein 0.5s forwards; -} - -@keyframes backfadein { - 100% { - opacity: 1; - } -} - -.hero h1 { - font: bold 60px "Open Sans", sans-serif; - margin-bottom: 15px; - text-shadow: 2px 2px #696969; -} - -.hero h3 { - font: normal 28px "Open Sans", sans-serif; - margin-bottom: 40px; -} - -.hero a.btn { - padding: 20px 46px; -} - -.hero-content-area { - opacity: 0; - margin-top: 100px; - animation: 1s slidefade 1s forwards; -} - -@keyframes slidefade { - 100% { - opacity: 1; - margin: 0; - } -} - -@media (max-width: 800px) { - .hero { - min-height: 600px; - } - .hero h1 { - font-size: 48px; - } - .hero h3 { - font-size: 24px; - } - .hero a.btn { - padding: 15px 40px; - } -} */ - -/* ABOUT SECTION */ - -/* #about .grid li { - height: 350px; - padding: 20px; - background-clip: content-box; - background-size: cover; - background-position: center; -} - -#about .grid li.small { - flex-basis: 30%; -} - -#about .grid li.large { - flex-basis: 70%; -} - -@media (max-width: 1100px) { - #about .grid li.small, - #about .grid li.large { - flex-basis: 50%; - } -} - -@media (max-width: 800px) { - #about .grid li.small, - #about .grid li.large { - flex-basis: 100%; - } -} */ - -/* EVENTS SECTION */ - -/* #events .grid li { - padding: 50px; - flex-basis: 50%; - text-align: center; -} - -#events .grid li i { - color: #8c9eff; -} - -#events .grid li h4 { - font-size: 30px; - margin: 25px; -} - -@media (max-width: 800px) { - #events .grid li { - flex-basis: 100%; - padding: 20px; - } -} */ - -/* CONTRIBUTORS SECTION */ - -/* #contributors .quote { - font-size: 22px; - font-weight: 300; - line-height: 1.5; - margin: 40px 0 25; -} - -@media (max-width: 800px) { - #contributors .quote { - font-size: 18px; - margin: 15px 0; - } - #contributors .author { - font-size: 14px; - } -} */ - -/* CONTACT SECTION */ - -/* #contact .btn { - padding: 18px 42px; -} - -@media (max-width: 1000px) { - #contact form input { - flex-basis: 100%; - margin: 0 0 20px 0; - } -} */ - -/* FOOTER SECTION */ - -/* footer { - display: flex; - align-content: center; - justify-content: space-around; - background-color: #3f51b5; - color: #fff; - padding: 20px 0; -} - -footer ul { - display: flex; - align-self: center; -} - -footer ul li { - margin-left: 16px; -} - -footer p { - text-transform: uppercase; - font-size: 14px; - opacity: 0.6; - align-self: center; -} - -@media (max-width: 1100px) { - footer { - flex-direction: column; - } - footer p { - text-align: center; - margin-bottom: 20px; - } - footer ul li { - margin: 0 8px; - } -} */ diff --git a/server.js b/server.js index c057d35..5a4cd2b 100644 --- a/server.js +++ b/server.js @@ -1,14 +1,23 @@ const express = require('express') +const Buffer = require('buffer').Buffer +require('dotenv').config() +require('isomorphic-fetch') const app = express() -app.get('/api/customers', (req, res) => { - const customers = [ - {id: 1, firstName: 'Mike', lastName: 'Masterson'}, - {id: 2, firstName: 'Patrick', lastName: 'Porche'}, - {id: 3, firstName: 'Jane', lastName: 'Doe'} - ] - res.json(customers) +app.get('/api/github', (req, res) => { + + const url = 'https://api.github.com/repos/pporche87/queersintech/collaborators' + + fetch(url, { + headers: { + 'Authorization': `Basic ${new Buffer('process.env.USER:process.env.PASS').toString('base64')}` + } + }) + .then((data) => { + return data.json() + }) + .then(data => res.json(data)) }) const port = 5000 diff --git a/views/index.html b/views/index.html deleted file mode 100644 index 36a582c..0000000 --- a/views/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - Queers in Tech - - - - - - -
-

Queers in Tech

- -
- -
-
-
-

Queers in Tech

-

An inclusive community of queers and allies in technology

- Contact Us -
-
- -
-

About

-

Diversity and inclusion in tech is a topic we hear often. But how do we increase visibility and actually start to show up more as marginalized groups? This organization seeks to answer that question.

-
- -
- -
-

Workshops and Meetups

-

We get together twice a month to learn new technologies, grow our community, and enjoy talks from industry leaders (that are also queers) in tech.

-
- - -
- -
-

Queers in Tech Contributors:

-
-

In order for us to start occupying more space in the tech community, we have to start being seen, heard, and felt in the industry. Build more cool shit, jump on worthwhile projects, and start changing the world.

-

- Patrick E Porche Jr

-

I want to create an environment where all queers can get together and discuss inclusion in tech.

-

- Spencer Dezart-Smith

-
- -
-

Learn More

-

Information about our meetup and events coming soon!!!

-
- -
- - - - From 71cbdc8b5d2908d883a94ded2bcce523a4f63388 Mon Sep 17 00:00:00 2001 From: Michael Masterson Date: Fri, 12 Jan 2018 11:44:50 -0800 Subject: [PATCH 2/3] Changed authentication to utilize an OAUTH key --- server.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server.js b/server.js index 5a4cd2b..3c5b7e5 100644 --- a/server.js +++ b/server.js @@ -1,5 +1,4 @@ const express = require('express') -const Buffer = require('buffer').Buffer require('dotenv').config() require('isomorphic-fetch') @@ -11,7 +10,7 @@ app.get('/api/github', (req, res) => { fetch(url, { headers: { - 'Authorization': `Basic ${new Buffer('process.env.USER:process.env.PASS').toString('base64')}` + 'Authorization': `token ${process.env.OAUTH}` } }) .then((data) => { From e41af7726a1b7b42f500c4ef5f4607f05d6709cb Mon Sep 17 00:00:00 2001 From: Michael Masterson Date: Fri, 12 Jan 2018 16:58:51 -0800 Subject: [PATCH 3/3] Medium Api displaying --- server.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 3c5b7e5..dd6f931 100644 --- a/server.js +++ b/server.js @@ -13,12 +13,25 @@ app.get('/api/github', (req, res) => { 'Authorization': `token ${process.env.OAUTH}` } }) - .then((data) => { - return data.json() - }) + .then(data => data.json()) .then(data => res.json(data)) }) +app.get('/api/medium', (req, res) => { + + const url = 'http://rss2json.com/api.json?rss_url=https://medium.com/feed/queers-in-tech' + + fetch(url) + .then(data => data.json()) + .then(data => res.json(data)) +}) + +// GET https://api.medium.com/v1/users/{{userId}}/publications + +// GET https://api.medium.com/v1/publications/{{publicationId}}/contributors + +// GET https://medium.com/m/oauth/authorize?client_id=6e2ef59844b4&scope=basicProfile,listPublications&state=bunnys&response_type=code&redirect_uri=http://queersintech.com + const port = 5000 app.listen(port, () => console.log(`Server started on port ${port}`)) \ No newline at end of file