diff --git a/blogContent/posts/programming/media/CSTHEORY/PDAConstruction.svg b/blogContent/posts/programming/media/CSTHEORY/PDAConstruction.svg
index d106f5d..456784f 100644
--- a/blogContent/posts/programming/media/CSTHEORY/PDAConstruction.svg
+++ b/blogContent/posts/programming/media/CSTHEORY/PDAConstruction.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/config.json b/config.json
new file mode 100644
index 0000000..0e37fb7
--- /dev/null
+++ b/config.json
@@ -0,0 +1,10 @@
+{
+ "PORT": 8000,
+
+ "SESSION_SECRET": "random-data-to-seed-session-data",
+
+ "SQL_HOST": "sql-hostname",
+ "SQL_DATABASE": "sql-database-name",
+ "SQL_USER": "sql-user",
+ "SQL_PASSWORD": "sql-password"
+}
\ No newline at end of file
diff --git a/server.js b/server.js
index 3c154b4..9bcac45 100644
--- a/server.js
+++ b/server.js
@@ -5,40 +5,41 @@
* appropriate pages.
*/
-//http server
+/** Stores the configuration for the server */
+const config = require('./utils/configLoader').getConfig();
+
+/** Port for the server to run on */
+const port = config.PORT;
+
+/** http server */
const http = require('http');
-//used to parse the request URL
+/** used to parse the request URL */
const url = require('url');
-//express app
+/** express app */
const express = require("express");
-//express app
+/** express app */
const app = express();
-//server side logging
+/** server side logging */
const sql = require('./utils/sql');
-//Used for gzip compression
+/** Used for gzip compression */
const compression = require('compression');
-//used for file io
-const utils = require('./utils/utils.js');
-//Updates the site map whenever the server is started
+/**Updates the site map whenever the server is started */
const map = require('./utils/generateSiteMap.js');
map.main();
-//port for the server to run on
-const port = 8000;
-
-//session data for login
+/**session data for login */
const session = require('express-session');
-//Initializes sessions for login
-app.use(session({ secret: utils.getFileLine('../session_secret'), cookie: { maxAge: 6000000 }}));
+/**Initializes sessions for login */
+app.use(session({ secret: config.SESSION_SECRET, cookie: { maxAge: 6000000 }}));
const projects = ["/steam/"];
@@ -99,6 +100,4 @@ app.use(function(request, result)
app.use(compression());
-http.createServer(app).listen(port);
-
-
+http.createServer(app).listen(port);
\ No newline at end of file
diff --git a/utils/configLoader.js b/utils/configLoader.js
new file mode 100644
index 0000000..db2d3ca
--- /dev/null
+++ b/utils/configLoader.js
@@ -0,0 +1,33 @@
+const utils = require('../utils/utils');
+
+
+/**
+ * @author Jeffery Russell 11-24-18
+ *
+ * @type {{main: module.exports.main}}
+ */
+module.exports=
+ {
+
+ /**
+ *
+ * @returns {*|any}
+ */
+ getConfig: function()
+ {
+ const configContents = ["PORT", "SESSION_SECRET",
+ "SQL_HOST", "SQL_DATABASE", "SQL_PASSWORD"];
+
+ var config = utils.getFileAsJSON("./config.json");
+
+ for(var i = 0; i < configContents.length; i++)
+ {
+ if(!config.hasOwnProperty(configContents[i]))
+ {
+ console.log("Missing config property: " + configContents[i]);
+ process.exit(1);
+ }
+ }
+ return config;
+ }
+ }
diff --git a/utils/renderBlogPost.js b/utils/renderBlogPost.js
index 324fc6e..34d05ea 100644
--- a/utils/renderBlogPost.js
+++ b/utils/renderBlogPost.js
@@ -111,7 +111,7 @@ module.exports=
//this line prevents older versions of pandoc from including invalid cdm scripts
result = result.split("").join("");
-
+ result = result.split("").join("");
if(blocks == -1)
resolve(result);
diff --git a/utils/sql.js b/utils/sql.js
index c2521c0..bce6114 100644
--- a/utils/sql.js
+++ b/utils/sql.js
@@ -1,23 +1,32 @@
+/**
+ * Boated file which handles all the SQL
+ * queries ran by the server
+ *
+ * @author Jeffery Russell
+ */
+
const mysql = require('mysql');
+/** Sanitizer to clean user inputs and prevent SQL injections */
const sanitizer = require('sanitizer');
-const Promise = require('promise');
-
+/** Crypto package used for hashing */
const crypto = require('crypto');
+/** Used to parse post data */
const qs = require('querystring');
-const utils = require('../utils/utils.js');
+/** Used to load the config file from the disk */
+const config = require('../utils/configLoader').getConfig();
+/** SQL connection */
const con = mysql.createConnection({
- host: "localhost",
- user: "blog_user",
- password: utils.getFileLine('../sql_secret'),
- database: "jrtechs_blog"
+ host: config.SQL_HOST,
+ user: config.SQL_USER,
+ password: config.SQL_PASSWORD,
+ database: config.SQL_DATABASE
});
-
con.connect(function(err) {
if (err)
console.log(err);
diff --git a/utils/utils.js b/utils/utils.js
index e546e9e..76d7f9e 100644
--- a/utils/utils.js
+++ b/utils/utils.js
@@ -51,6 +51,17 @@ module.exports=
},
+ /**
+ *
+ * @param fileName
+ * @returns {any}
+ */
+ getFileAsJSON: function(fileName)
+ {
+ return JSON.parse(fs.readFileSync(fileName, 'utf8'));
+ },
+
+
/**
* Returns all the contents of a file as a single line
* with no break lines.