Browse Source

Created a node application to foster the creation of in-house api to cache and get at Github's api with a better throttle limit.

pull/11/head
Jeffery Russell 5 years ago
parent
commit
4ef9bbdeb2
3 changed files with 114 additions and 1 deletions
  1. +55
    -1
      js/friendsGraph.js
  2. +25
    -0
      package.json
  3. +34
    -0
      server.js

+ 55
- 1
js/friendsGraph.js View File

@ -37,6 +37,7 @@ function addPersonToGraph(profileData)
nodes.push(
{
id:profileData.id,
name:profileData.login,
shape: 'circularImage',
image:profileData.avatar_url
});
@ -66,12 +67,65 @@ function addFriends(username, apiPath)
function addConnection(person1, person2)
{
edges.push(
{
from: person1.id,
to: person2.id
});
}
function processUserConnections(userName)
{
return new Promise(function(resolve, reject)
{
queryAPIByUser(API_FOLLOWING, userName,
function(data)
{
for(var i = 0; i < data.length; i++)
{
}
queryAPIByUser(API_FOLLOWERS, userName, function(data2)
{
for(var i = 0; i < data2.length; i++)
{
}
resolve();
},
function(error)
{
reject(error);
});
},
function(error)
{
reject(error);
})
});
}
function createConnections()
{
return new Promise(function(resolve, reject)
{
resolve();
var prom = [];
for(var i = 0; i < nodes.length; i++)
{
prom.push(processUserConnections(nodes[i].name));
}
Promise.all(prom).then(function()
{
resolve();
}).catch(function(error)
{
reject(error);
});
});
}

+ 25
- 0
package.json View File

@ -0,0 +1,25 @@
{
"name": "github-graphs",
"version": "0.0.1",
"description": "Generates graphs of github things.",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jrtechs/github-graphs.git"
},
"author": "Jeffery Russell",
"license": "ISC",
"bugs": {
"url": "https://github.com/jrtechs/github-graphs/issues"
},
"homepage": "https://github.com/jrtechs/github-graphs#readme",
"dependencies": {
"express": "^4.16.4",
"express-session": "^1.15.6",
"fs": "0.0.1-security"
}
}

+ 34
- 0
server.js View File

@ -0,0 +1,34 @@
/** express app for routing */
const express = require("express");
/**session data for login and storing preferences*/
const session = require('express-session');
const configLoader = require('./configManager.js');
const app = express();
/**Initializes sessions for login */
app.use(session(
{ secret: configLoader.getConfiguration().sessionSecret,
cookie: { maxAge: 6000000 }}
));
app.use(express.urlencoded()); //for easy retrieval of post and get data
app.use(express.json());
app.use(express.static('css'));
app.use(express.static('js'));
app.use(express.static('img'));
app.use(express.static('html'));
const routes = require('./routes');
app.use('/', routes);
app.listen(configLoader.getConfiguration().port, () =>
console.log(`App listening on port ${configLoader.getConfiguration().port}!`)
);

Loading…
Cancel
Save