mybase 1.1.40 → 1.1.41
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.
- package/package.json +2 -1
- package/ts/funcs/knexConnection.d.ts +8 -0
- package/ts/funcs/knexConnection.js +44 -0
- package/ts/funcs/knexConnection.ts +42 -0
- package/ts/index.d.ts +1 -0
- package/ts/index.js +1 -0
- package/ts/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mybase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.41",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "mybase.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"ip6": "=0.2.7",
|
|
24
24
|
"ip6addr": "github:7c/node-ip6addr#db6d558af1f314bcb0a733fd61611fa85e1a3eff",
|
|
25
25
|
"js-sha512": "^0.8.0",
|
|
26
|
+
"knex": "^3.1.0",
|
|
26
27
|
"mysql": "^2.18.1",
|
|
27
28
|
"mysql2": "^3.9.1",
|
|
28
29
|
"node-vault": "^0.10.2",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import knex from "knex";
|
|
2
|
+
export declare function knexConnection(connection: {
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
password: string;
|
|
6
|
+
db: string;
|
|
7
|
+
login: string;
|
|
8
|
+
}, poolConfiguration?: knex.Knex.PoolConfig, acquireConnectionTimeout?: number, debug?: boolean): knex.Knex<any, unknown[]>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.knexConnection = void 0;
|
|
7
|
+
const debug_1 = __importDefault(require("debug"));
|
|
8
|
+
const knex_1 = __importDefault(require("knex"));
|
|
9
|
+
const dbg = (0, debug_1.default)('_knexConnection');
|
|
10
|
+
function knexConnection(connection, poolConfiguration = {
|
|
11
|
+
min: 1,
|
|
12
|
+
max: 10
|
|
13
|
+
}, acquireConnectionTimeout = 10000, debug = false) {
|
|
14
|
+
return (0, knex_1.default)({
|
|
15
|
+
client: 'mysql2',
|
|
16
|
+
debug,
|
|
17
|
+
connection: {
|
|
18
|
+
host: connection.host,
|
|
19
|
+
port: connection.port,
|
|
20
|
+
password: connection.password,
|
|
21
|
+
database: connection.db,
|
|
22
|
+
user: connection.login
|
|
23
|
+
},
|
|
24
|
+
pool: poolConfiguration,
|
|
25
|
+
acquireConnectionTimeout,
|
|
26
|
+
log: {
|
|
27
|
+
warn(message) {
|
|
28
|
+
dbg('knex warn', message);
|
|
29
|
+
},
|
|
30
|
+
error(message) {
|
|
31
|
+
dbg('knex error', message);
|
|
32
|
+
},
|
|
33
|
+
deprecate(message) {
|
|
34
|
+
dbg('knex deprecate', message);
|
|
35
|
+
},
|
|
36
|
+
debug(message) {
|
|
37
|
+
if (debug)
|
|
38
|
+
console.log('knex debug', message);
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
exports.knexConnection = knexConnection;
|
|
44
|
+
//# sourceMappingURL=knexConnection.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import debug from "debug"
|
|
2
|
+
import knex from "knex"
|
|
3
|
+
const dbg = debug('_knexConnection')
|
|
4
|
+
|
|
5
|
+
export function knexConnection(connection:{
|
|
6
|
+
host: string,
|
|
7
|
+
port: number,
|
|
8
|
+
password: string,
|
|
9
|
+
db: string,
|
|
10
|
+
login: string
|
|
11
|
+
}, poolConfiguration:knex.Knex.PoolConfig= {
|
|
12
|
+
min: 1,
|
|
13
|
+
max: 10
|
|
14
|
+
}, acquireConnectionTimeout:number=10000, debug: boolean = false) {
|
|
15
|
+
return knex({
|
|
16
|
+
client: 'mysql2',
|
|
17
|
+
debug,
|
|
18
|
+
connection:{
|
|
19
|
+
host: connection.host,
|
|
20
|
+
port: connection.port,
|
|
21
|
+
password: connection.password,
|
|
22
|
+
database: connection.db,
|
|
23
|
+
user: connection.login
|
|
24
|
+
},
|
|
25
|
+
pool: poolConfiguration,
|
|
26
|
+
acquireConnectionTimeout,
|
|
27
|
+
log: {
|
|
28
|
+
warn(message: string) {
|
|
29
|
+
dbg('knex warn', message)
|
|
30
|
+
},
|
|
31
|
+
error(message: string) {
|
|
32
|
+
dbg('knex error', message)
|
|
33
|
+
},
|
|
34
|
+
deprecate(message: string) {
|
|
35
|
+
dbg('knex deprecate', message)
|
|
36
|
+
},
|
|
37
|
+
debug(message: string) {
|
|
38
|
+
if (debug) console.log('knex debug', message)
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
} as knex.Knex.Config)
|
|
42
|
+
}
|
package/ts/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./funcs/initMysql2Pool";
|
|
|
25
25
|
export * from "./funcs/randomUTFString";
|
|
26
26
|
export * from "./funcs/MaxRuntimeHours";
|
|
27
27
|
export * from "./funcs/ensureFolder";
|
|
28
|
+
export * from "./funcs/knexConnection";
|
|
28
29
|
export * from "./models/Unixtime";
|
|
29
30
|
export * from "./models/Timespan";
|
|
30
31
|
export * from "./models/IPAddress";
|
package/ts/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __exportStar(require("./funcs/initMysql2Pool"), exports);
|
|
|
41
41
|
__exportStar(require("./funcs/randomUTFString"), exports);
|
|
42
42
|
__exportStar(require("./funcs/MaxRuntimeHours"), exports);
|
|
43
43
|
__exportStar(require("./funcs/ensureFolder"), exports);
|
|
44
|
+
__exportStar(require("./funcs/knexConnection"), exports);
|
|
44
45
|
// models
|
|
45
46
|
__exportStar(require("./models/Unixtime"), exports);
|
|
46
47
|
__exportStar(require("./models/Timespan"), exports);
|