This commit is contained in:
Jan Prochazka
2020-02-03 20:44:06 +01:00
parent 8a85cfe687
commit e903122c52
4 changed files with 14 additions and 8 deletions

5
packages/engines/index.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
import types from "@dbgate/types";
export function getDriver(
connection: string | { engine: string }
): types.EngineDriver;

View File

@@ -1,15 +1,15 @@
const _ = require("lodash");
const mssql = require('./mssql');
const mysql = require('./mysql');
const postgres = require('./postgres');
const mssql = require("./mssql");
const mysql = require("./mysql");
const postgres = require("./postgres");
const drivers = {
mssql,
mysql,
postgres,
}
postgres
};
/** @return {import('@dbgate/types').EngineDriver} */
/** @type {import('@dbgate/types').EngineDriver} */
function getDriver(connection) {
if (_.isString(connection)) {
return drivers[connection];
@@ -20,6 +20,6 @@ function getDriver(connection) {
return drivers[engine];
}
}
throw new Error(`Cannot extract engine from ${connection}`)
throw new Error(`Cannot extract engine from ${connection}`);
}
module.exports = getDriver;

View File

@@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"main": "index.js",
"typings": "./index.d.ts",
"devDependencies": {
"@dbgate/types": "^0.1.0",
"@types/lodash": "^4.14.149",

View File

@@ -12,6 +12,6 @@
],
},
"include": [
"src"
"."
]
}