diff --git a/app.js b/app.js
index 5ec46e9..5218cda 100644
--- a/app.js
+++ b/app.js
@@ -6,25 +6,31 @@ app.use(cookieParser());
var uuid = require("uuid/v4");
var mysql = require("mysql");
+var fs = require("fs");
+var cause;
+const __ssl_dir = ""
var con = mysql.createConnection({
host: "localhost",
user: "minis",
password: "Wnc4q_75",
- database: "minis"
+ database: "minis",
+ ssl: {
+ rejectUnauthorized: false
+ }
});
con.connect(err => {
if (err) {
console.log("Cant connect to MySQL database");
- throw err;
+ cause = err;
}
console.log("Connected to database!");
});
app.get('/', (req, res) => {
- if(!isConnected()){res.send("No Connection to database");return}
+ if(!isConnected()){res.send("No Connection to database
" + JSON.stringify(cause) + "
" + toString(con));return}
res.send("Welcome to the miniplan api!");
});
@@ -139,6 +145,22 @@ app.listen(3000, () => {
console.log("API started!");
});
+function toString(string){
+ var cache = [];
+ var r = JSON.stringify(string, function(key, value) {
+ if (typeof value === 'object' && value !== null) {
+ if (cache.indexOf(value) !== -1) {
+ // Circular reference found, discard key
+ return;
+ }
+ // Store value in our collection
+ cache.push(value);
+ }
+ return value;
+ });
+ cache = null; // Enable garbage collection
+ return r;
+}
function isConnected(){
if(con.isConnected){