badmfck-api-server 3.6.4 → 3.6.6
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.
@@ -95,7 +95,7 @@ async function Initializer(services) {
|
|
95
95
|
exports.Initializer = Initializer;
|
96
96
|
class APIService extends BaseService_1.BaseService {
|
97
97
|
static nextLogID = 0;
|
98
|
-
version = "3.6.
|
98
|
+
version = "3.6.6";
|
99
99
|
options;
|
100
100
|
monitor = null;
|
101
101
|
started = new Date();
|
@@ -3,15 +3,15 @@ import { BaseService } from "./BaseService";
|
|
3
3
|
import Signal, { Req } from "badmfck-signal";
|
4
4
|
import * as mysql from "mysql2/promise";
|
5
5
|
import fs from "fs";
|
6
|
-
export declare const
|
7
|
-
export declare const
|
8
|
-
export declare const
|
9
|
-
export declare const
|
6
|
+
export declare const DEPRECATED_S_MYSQL_STARTED: Signal<void>;
|
7
|
+
export declare const DEPRECATED_REQ_MYSQL_QUERY: Req<MySqlQuery | MySqlQuery[], MysqlResult[]>;
|
8
|
+
export declare const DEPRECATED_REQ_MYSQL_TBEGIN: Req<void, number | MysqlError>;
|
9
|
+
export declare const DEPRECATED_REQ_MYSQL_TQUERY: Req<{
|
10
10
|
query: MySqlQuery;
|
11
11
|
tid: number;
|
12
12
|
}, MysqlResult>;
|
13
|
-
export declare const
|
14
|
-
export declare const
|
13
|
+
export declare const DEPRECATED_REQ_MYSQL_TCOMMIT: Req<number, MysqlError | null>;
|
14
|
+
export declare const DEPRECATED_REQ_MYSQL_TROLLBACK: Req<number, MysqlError | null>;
|
15
15
|
export declare const executeQuery: (query: MySqlQuery | MySqlQuery[]) => Promise<MysqlResult[]>;
|
16
16
|
export interface MysqlServiceOptions {
|
17
17
|
connectionLimit: number;
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.MysqlService = exports.isMysqlError = exports.executeQuery = exports.
|
29
|
+
exports.MysqlService = exports.isMysqlError = exports.executeQuery = exports.DEPRECATED_REQ_MYSQL_TROLLBACK = exports.DEPRECATED_REQ_MYSQL_TCOMMIT = exports.DEPRECATED_REQ_MYSQL_TQUERY = exports.DEPRECATED_REQ_MYSQL_TBEGIN = exports.DEPRECATED_REQ_MYSQL_QUERY = exports.DEPRECATED_S_MYSQL_STARTED = void 0;
|
30
30
|
const BaseService_1 = require("./BaseService");
|
31
31
|
const badmfck_signal_1 = __importStar(require("badmfck-signal"));
|
32
32
|
const crypto_1 = require("crypto");
|
@@ -34,13 +34,13 @@ const LogService_1 = require("./LogService");
|
|
34
34
|
const mysql = __importStar(require("mysql2/promise"));
|
35
35
|
const fs_1 = __importDefault(require("fs"));
|
36
36
|
const path_1 = __importDefault(require("path"));
|
37
|
-
exports.
|
38
|
-
exports.
|
39
|
-
exports.
|
40
|
-
exports.
|
41
|
-
exports.
|
42
|
-
exports.
|
43
|
-
const executeQuery = async (query) => { return await exports.
|
37
|
+
exports.DEPRECATED_S_MYSQL_STARTED = new badmfck_signal_1.default();
|
38
|
+
exports.DEPRECATED_REQ_MYSQL_QUERY = new badmfck_signal_1.Req(undefined, "REQ_MYSQL_QUERY");
|
39
|
+
exports.DEPRECATED_REQ_MYSQL_TBEGIN = new badmfck_signal_1.Req(undefined, "REQ_MYSQL_TRANSACTION_BEGING");
|
40
|
+
exports.DEPRECATED_REQ_MYSQL_TQUERY = new badmfck_signal_1.Req(undefined, "REQ_MYSQL_TRANSACTION_ADD_OPERATION");
|
41
|
+
exports.DEPRECATED_REQ_MYSQL_TCOMMIT = new badmfck_signal_1.Req(undefined, "REQ_MYSQL_TCOMMIT");
|
42
|
+
exports.DEPRECATED_REQ_MYSQL_TROLLBACK = new badmfck_signal_1.Req(undefined, "REQ_MYSQL_TROLLBACK");
|
43
|
+
const executeQuery = async (query) => { return await exports.DEPRECATED_REQ_MYSQL_QUERY.request(query); };
|
44
44
|
exports.executeQuery = executeQuery;
|
45
45
|
const isMysqlError = (e) => {
|
46
46
|
return e.code !== undefined && e.errno !== undefined && e.sql !== undefined && e.name !== undefined && e.message !== undefined;
|
@@ -96,7 +96,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
96
96
|
if (!this.pool)
|
97
97
|
return;
|
98
98
|
for (let i = 0; i < this.options.connectionLimit; i++) {
|
99
|
-
exports.
|
99
|
+
exports.DEPRECATED_REQ_MYSQL_QUERY.request({ query: "SELECT 1 @NOLIMIT", fields: [] });
|
100
100
|
if (this.debug)
|
101
101
|
console.log("Ping mysql on each connection in pool");
|
102
102
|
}
|
@@ -122,7 +122,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
122
122
|
}
|
123
123
|
}
|
124
124
|
}
|
125
|
-
static async executeQuery(query) { return await exports.
|
125
|
+
static async executeQuery(query) { return await exports.DEPRECATED_REQ_MYSQL_QUERY.request(query); }
|
126
126
|
async init() {
|
127
127
|
super.init();
|
128
128
|
process.on('SIGINT', async () => {
|
@@ -143,7 +143,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
143
143
|
await new Promise((resolve) => setTimeout(resolve, 3000));
|
144
144
|
}
|
145
145
|
}
|
146
|
-
exports.
|
146
|
+
exports.DEPRECATED_REQ_MYSQL_QUERY.listener = async (data) => {
|
147
147
|
if (!Array.isArray(data))
|
148
148
|
data = [data];
|
149
149
|
const promises = [];
|
@@ -169,7 +169,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
169
169
|
}
|
170
170
|
return result;
|
171
171
|
};
|
172
|
-
exports.
|
172
|
+
exports.DEPRECATED_REQ_MYSQL_TBEGIN.listener = async () => {
|
173
173
|
const conn = await this.pool?.getConnection();
|
174
174
|
if (!conn)
|
175
175
|
return { code: "NO_POOL", errno: 100000, fatal: true, sql: "", name: "NO_POOL", message: "Mysql pool not created", throwable: false };
|
@@ -201,7 +201,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
201
201
|
console.log("Transactions pool: ", this.transactions);
|
202
202
|
return tid;
|
203
203
|
};
|
204
|
-
exports.
|
204
|
+
exports.DEPRECATED_REQ_MYSQL_TQUERY.listener = async (data) => {
|
205
205
|
const trx = this.transactions.find(i => i.id === data.tid);
|
206
206
|
if (!trx)
|
207
207
|
return { err: {
|
@@ -249,7 +249,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
249
249
|
count: count
|
250
250
|
};
|
251
251
|
};
|
252
|
-
exports.
|
252
|
+
exports.DEPRECATED_REQ_MYSQL_TROLLBACK.listener = async (tid) => {
|
253
253
|
const trx = this.transactions.find(i => i.id === tid);
|
254
254
|
if (!trx) {
|
255
255
|
return {
|
@@ -265,7 +265,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
265
265
|
await this.rollbackTransaction(trx);
|
266
266
|
return null;
|
267
267
|
};
|
268
|
-
exports.
|
268
|
+
exports.DEPRECATED_REQ_MYSQL_TCOMMIT.listener = async (tid) => {
|
269
269
|
const trx = this.transactions.find(i => i.id === tid);
|
270
270
|
if (!trx) {
|
271
271
|
return {
|
@@ -193,7 +193,7 @@ class MysqlAdapter {
|
|
193
193
|
trxRequest.queries.push({ sql: "START TRANSACTION", status: "ok" });
|
194
194
|
this.transactions.push(trxRequest);
|
195
195
|
if (this.options.debug)
|
196
|
-
(0, LogService_1.logDB)("Transactions pool: ", this.transactions);
|
196
|
+
(0, LogService_1.logDB)("Transactions pool: ", this.transactions.map(t => "id:" + t.id + ", queries: " + t.queries.length));
|
197
197
|
return { data: { transactionId: trxid } };
|
198
198
|
}
|
199
199
|
async tCommit(trxid) {
|