@ -0,0 +1,7 @@ | |||
{ | |||
"port": 7000, | |||
"sessionSecret": "superDuperSecret", | |||
"clientID": "github client id", | |||
"clientSecret": "clientSecret" | |||
} |
@ -0,0 +1,33 @@ | |||
const fileIO = require('./fileIO'); | |||
const CONFIG_FILE_NAME = "conf.json"; | |||
const config = fileIO.getFileAsJSON(CONFIG_FILE_NAME); | |||
module.exports= | |||
{ | |||
getConfiguration: function() | |||
{ | |||
return config; | |||
}, | |||
syncToDisk: function() | |||
{ | |||
fileIO.writeJSONToFile(CONFIG_FILE_NAME, config); | |||
}, | |||
getPort: function() | |||
{ | |||
return config.port; | |||
}, | |||
getClientID: function() | |||
{ | |||
return config.clientID; | |||
}, | |||
getClientSecret: function() | |||
{ | |||
return config.clientSecret; | |||
} | |||
}; |
@ -0,0 +1,32 @@ | |||
/** Used to read and write files from disk */ | |||
const fs = require('fs'); | |||
module.exports = | |||
{ | |||
writeJSONToFile: function(fileName, jsonObject) | |||
{ | |||
const json = JSON.stringify(jsonObject, null, 4); | |||
fs.writeFile(fileName, json, 'utf8', function() | |||
{ | |||
console.log("Wrote to " + fileName); | |||
}); | |||
}, | |||
/** | |||
* | |||
* @param fileName | |||
* @returns {any} | |||
*/ | |||
getFileAsJSON: function(fileName) | |||
{ | |||
return JSON.parse(module.exports.getFile(fileName)); | |||
}, | |||
getFile: function(filename) | |||
{ | |||
return fs.readFileSync(filename, 'utf8'); | |||
} | |||
}; |
@ -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" | |||
} | |||
} |
@ -0,0 +1,36 @@ | |||
/** 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(__dirname,'css')); | |||
app.use(express.static(__dirname, 'js')); | |||
app.use(express.static(__dirname, 'img')); | |||
app.use(express.static('html')); | |||
app.use(express.static(__dirname, 'fonts')); | |||
const routes = require('./routes'); | |||
app.use('/', routes); | |||
app.listen(configLoader.getConfiguration().port, () => | |||
console.log(`App listening on port ${configLoader.getConfiguration().port}!`) | |||
); |