From 73eb4d50427c7368216611bbc6c852c7aaede12d Mon Sep 17 00:00:00 2001 From: Walamana Date: Mon, 27 Nov 2017 17:56:30 +0100 Subject: [PATCH] ssl ca Signed-off-by: Walamana --- app.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) 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){