Browse Source

Merge branch 'master' of github.com:jrtechs/github-graphs

pull/11/head
Bryce Murphy 5 years ago
parent
commit
544011c28f
9 changed files with 116 additions and 11 deletions
  1. +5
    -0
      configManager.js
  2. +2
    -1
      package.json
  3. +3
    -0
      public/about.css
  4. +13
    -5
      public/about.html
  5. +1
    -1
      public/js/githubAPI.js
  6. +3
    -3
      public/style.css
  7. +70
    -0
      routes/api.js
  8. +17
    -0
      routes/index.js
  9. +2
    -1
      server.js

+ 5
- 0
configManager.js View File

@ -33,6 +33,11 @@ module.exports=
getSessionSecret: function()
{
return config.sessionSecret;
},
getAPIUser: function()
{
return config.user;
}
};

+ 2
- 1
package.json View File

@ -20,6 +20,7 @@
"dependencies": {
"express": "^4.16.4",
"express-session": "^1.15.6",
"fs": "0.0.1-security"
"fs": "0.0.1-security",
"got": "^9.6.0"
}
}

+ 3
- 0
public/about.css View File

@ -16,6 +16,9 @@
position: relative;
background-color: rgb(242, 242, 242);
border-radius: 0px 0px 20px 20px;
}
.plink {
}
body {
background-color: #232323;

+ 13
- 5
public/about.html View File

@ -1,4 +1,4 @@
<!doctype html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
@ -11,7 +11,7 @@
<div id="header-bar" class="d-flex flex-column flex-md-row shadow-sm align-items-center">
<div id="header-title">
<a href="./index.html">
<img id="icon" src="./logo.svg" />
<img id="logo" src="./logo.svg" />
</a>
</div>
<ul id="navigation" class="nav justify-content-end">
@ -37,11 +37,19 @@
<div id="main">
<div id="content" class="container">
<div id="content-title">
<h1 class="big-title text-center">Developers</h1>
<h1 class="big-title text-center">What is this?</h1>
</div>
<div id="content-body" class="container">
<p>
some stuff will go here
<p style="padding: 10px;">
jeff this is where you can write a bunch about the project
</p>
</div>
<div id="content-title">
<h1 class="big-title text-center">Why did you make this?</h1>
</div>
<div id="content-body" class="container">
<p style="padding: 10px;">
This project was made for participation in <a class="plink" href="https://brickhack.io/">BrickHack V</a>.
</p>
</div>
</div>

+ 1
- 1
public/js/githubAPI.js View File

@ -7,7 +7,7 @@
*/
const APIROOT = "https://api.github.com";
const APIROOT = "api";
const API_USER_PATH = "/users/";

+ 3
- 3
public/style.css View File

@ -24,7 +24,7 @@
font-size: 25px;
}
#logo {
height: 40px;
height: 60px;
}
#navigation {
width: 70%;
@ -47,11 +47,11 @@
padding: 5px;
font-size: 20px;
}
a {
.nav-item a {
color: #232323;
text-decoration: none;
}
a:hover {
.nav-item a:hover {
color: rgb(57, 163, 225);
text-decoration: none;
}

+ 70
- 0
routes/api.js View File

@ -0,0 +1,70 @@
const routes = require('express').Router();
const got = require("got");
const GITHUB_API = "https://api.github.com";
const configLoader = require('../configManager');
const authenticate = "?client_id=" + configLoader.getClientID() +
"&client_secret=" + configLoader.getClientSecret();
function queryGitHubAPI(requestURL)
{
return new Promise(function(reject, resolve)
{
const queryRUL = GITHUB_API + requestURL + authenticate;
got(queryRUL, { json: true }).then(response =>
{
resolve(response.body);
}).catch(error =>
{
resolve(response.body)
});
})
}
//https://api.github.com/users/whatever?client_id=xxxx&client_secret=yyyy
// function authenticateWithGitHub()
// {
// const authURL = GITHUB_API + "/users/" + configLoader.getAPIUser() + "?client_id=" + configLoader.getClientID() +
// "&client_secret=" + configLoader.getClientSecret();
//
// return new Promise(function(resolve, reject)
// {
// got(authURL, { json: true }).then(response =>
// {
// console.log(response);
// resolve(response);
// }).catch(error => {
// reject(error);
// console.log(error.response.body);
// });
// })
//
// }
routes.get('/*', (request, result) =>
{
const gitHubAPIURL = request.url;
queryGitHubAPI(gitHubAPIURL).then(function(data)
{
result.write(JSON.stringify(data));
result.end();
}).catch(function(error)
{
result.write(JSON.stringify(error));
result.end();
})
});
module.exports = routes;

+ 17
- 0
routes/index.js View File

@ -0,0 +1,17 @@
const routes = require('express').Router();
const api = require('./api');
routes.use('/api', api);
routes.get("/", (request, result) =>
{
result.redirect("index.html");
});
routes.get('*', (request, result) =>
{
result.redirect("404.html");
});
module.exports = routes;

+ 2
- 1
server.js View File

@ -21,12 +21,13 @@ app.use(express.json());
app.use(express.static('public'));
const routes = require('./routes');
app.use('/', routes);
app.listen(configLoader.getConfiguration().port, () =>
console.log(`App listening on port ${configLoader.getPort()}!`)
);

Loading…
Cancel
Save