engine resolve refactor

This commit is contained in:
Jan Prochazka 2020-01-05 09:39:41 +01:00
parent 43b9304c7e
commit 0e860e8ba3
3 changed files with 10 additions and 2 deletions

4
api/src/engines/index.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = connection => {
const { engine } = connection;
return require(`./${engine}`);
};

View File

@ -1,6 +1,8 @@
const engines = require('../engines');
process.on('message', async connection => {
try {
const driver = require(`../engines/${connection.engine}/index`);
const driver = engines(connection);
const conn = await driver.connect(connection);
const res = await driver.getVersion(conn);
process.send(res);

View File

@ -1,8 +1,10 @@
const engines = require('../engines');
let systemConnection;
let storedConnection;
async function handleRefreshDatabases() {
const driver = require(`../engines/${storedConnection.engine}/index`);
const driver = engines(storedConnection);
const databases = await driver.listDatabases(systemConnection);
process.send({ msgtype: 'databases', databases });
}