mielk-api 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,6 +4,7 @@ let connectionString = '';
|
|
|
4
4
|
export const initDb = (dbConfig) => {
|
|
5
5
|
const { host, database, user, password, driver } = dbConfig;
|
|
6
6
|
connectionString = `Server=${host};Database=${database};UID=${user};PWD=${password};Driver=${driver}`;
|
|
7
|
+
console.log(connectionString);
|
|
7
8
|
};
|
|
8
9
|
export const query = (queryText) => {
|
|
9
10
|
return new Promise((resolve, reject) => {
|
|
@@ -9,8 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { Msg } from '../../../internal/messaging/messageTags.js';
|
|
11
11
|
import { Pool } from 'pg';
|
|
12
|
-
import { openSshTunnel } from './tunnel.js';
|
|
13
|
-
import { isProd } from '../../../routing/express.js';
|
|
14
12
|
let pool = null;
|
|
15
13
|
let config = null;
|
|
16
14
|
export const initDb = (dbConfig) => {
|
|
@@ -22,12 +20,11 @@ export function getPool() {
|
|
|
22
20
|
return pool;
|
|
23
21
|
if (config === null)
|
|
24
22
|
throw new Error(Msg.connection.notInitialized);
|
|
25
|
-
if (!isProd()) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
23
|
+
// if (!isProd()) {
|
|
24
|
+
// if (!config.ssh) throw new Error(Msg.connection.sshOptionsNotSpecified)
|
|
25
|
+
// const port: number = await openSshTunnel(config.ssh, config.port);
|
|
26
|
+
// config.port = port;
|
|
27
|
+
// }
|
|
31
28
|
pool = new Pool(config);
|
|
32
29
|
pool.on('error', (err) => {
|
|
33
30
|
console.error(Msg.connection.postgreConnectionError, err);
|
|
@@ -11,10 +11,10 @@ import * as postgreRepository from '../repositories/postgre.repository.js';
|
|
|
11
11
|
import * as msSqlRepository from '../repositories/mssql.repository.js';
|
|
12
12
|
import { getDbProvider } from '../express.js';
|
|
13
13
|
import { Msg } from '../../internal/messaging/messageTags.js';
|
|
14
|
-
const provider = getDbProvider();
|
|
15
|
-
const repository = provider === 'postgre' ? postgreRepository : provider === 'mssql' ? msSqlRepository : undefined;
|
|
16
14
|
export function getDatabaseTime() {
|
|
17
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const provider = getDbProvider();
|
|
17
|
+
const repository = provider === 'postgre' ? postgreRepository : provider === 'mssql' ? msSqlRepository : undefined;
|
|
18
18
|
if (repository) {
|
|
19
19
|
return repository.selectDatabaseTime();
|
|
20
20
|
}
|
|
@@ -23,6 +23,8 @@ export function getDatabaseTime() {
|
|
|
23
23
|
}
|
|
24
24
|
export function getDatabaseVersion() {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const provider = getDbProvider();
|
|
27
|
+
const repository = provider === 'postgre' ? postgreRepository : provider === 'mssql' ? msSqlRepository : undefined;
|
|
26
28
|
if (repository) {
|
|
27
29
|
return repository.selectDatabaseVersion();
|
|
28
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mielk-api",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "mielk",
|
|
6
6
|
"description": "Wrapper for API operations",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"license": "MIT",
|
|
45
45
|
"repository": {
|
|
46
46
|
"type": "git",
|
|
47
|
-
"url": "git+https://github.com/mielk/mielk-api
|
|
47
|
+
"url": "git+https://github.com/mielk/mielk-api.git"
|
|
48
48
|
},
|
|
49
|
-
"homepage": "https://mielk.github.io/mielk-api
|
|
49
|
+
"homepage": "https://mielk.github.io/mielk-api/",
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@babel/cli": "^7.25.7",
|
|
52
52
|
"@babel/core": "^7.25.8",
|