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

View File

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

View File

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