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 fs = require('fs');
const path = require('path'); const path = require('path');
const nanoid = require('nanoid'); const nanoid = require('nanoid');
const tunnel = require('tunnel-ssh');
var dbOptions = { var dbOptions = {
db: db, db: db,
@ -55,10 +54,8 @@ module.exports = function () {
db.sequelize = dbOptions.sequelize; db.sequelize = dbOptions.sequelize;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
tunneling() dbOptions.sequelize.sync()
.then(() => { .then(() => {
return dbOptions.sequelize.sync()
}).then(() => {
resolve(db); resolve(db);
}).catch(error => { }).catch(error => {
// Do the things... // Do the things...
@ -83,45 +80,7 @@ module.exports = function () {
reject(error); reject(error);
console.error('Unable to connect to the database:', error); 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; return db;
}; };