Getting rid of unused components

This commit is contained in:
Kgothatso 2019-12-06 23:48:45 +02:00
parent 44fcf30df8
commit c6797ee6cc

View File

@ -7,7 +7,6 @@ module.exports = function () {
const fs = require('fs');
const path = require('path');
const nanoid = require('nanoid');
const tunnel = require('tunnel-ssh');
var dbOptions = {
db: db,
@ -55,10 +54,8 @@ module.exports = function () {
db.sequelize = dbOptions.sequelize;
return new Promise((resolve, reject) => {
tunneling()
dbOptions.sequelize.sync()
.then(() => {
return dbOptions.sequelize.sync()
}).then(() => {
resolve(db);
}).catch(error => {
// Do the things...
@ -84,44 +81,6 @@ module.exports = function () {
console.error('Unable to connect to the database:', error);
})
})
}
var tunneling = () => {
const tunnelConfigs = config.get("tunnel");
return new Promise((resolve, reject) => {
if(tunnelConfigs.useTunnel) {
const privateKeyFilePath = path.resolve(tunnelConfigs["privateKeyFilePath"]);
// Run the tunnel...
var sshConfig = {
"keepAlive": tunnelConfigs["keepAlive"],
"username": tunnelConfigs["username"],
// "password": tunnelConfigs["password"],
"host": tunnelConfigs["host"],
"port": tunnelConfigs["port"],
"dstHost": tunnelConfigs["dstHost"],
"dstPort": tunnelConfigs["dstPort"],
// "localHost": tunnelConfigs["localHost"],
"localPort": tunnelConfigs["localPort"],
"privateKey": fs.readFileSync(privateKeyFilePath),
"passphrase": tunnelConfigs["passphrase"]
}
console.log("Private Key path: ", privateKeyFilePath);
tunnel(sshConfig, (error, server) => {
if(error) {
console.error("Tunneling: ", error);
reject(error);
} else {
console.log('Tunnel server:', server);
resolve(server)
}
})
} else {
// Continue without setting up a tunnel...
resolve();
}
})
}
return db;
};