ssl ca
Signed-off-by: Walamana <joniogerg@gmail.com>
This commit is contained in:
parent
2b6281d96d
commit
73eb4d5042
28
app.js
28
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<br>" + JSON.stringify(cause) + "<br>" + 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){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user