From c6797ee6cc44fc67fb936d209420624ba9c6ff5f Mon Sep 17 00:00:00 2001 From: Kgothatso Date: Fri, 6 Dec 2019 23:48:45 +0200 Subject: [PATCH] Getting rid of unused components --- persistence/persistence.js | 45 ++------------------------------------ 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/persistence/persistence.js b/persistence/persistence.js index 1c988ad..16c4ac1 100644 --- a/persistence/persistence.js +++ b/persistence/persistence.js @@ -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... @@ -83,45 +80,7 @@ module.exports = function () { reject(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; };