badmfck-api-server 1.1.8 → 1.2.0
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.
|
@@ -36,7 +36,8 @@ export declare class MysqlService extends BaseService {
|
|
|
36
36
|
reconnecting: boolean;
|
|
37
37
|
pool: Pool | null;
|
|
38
38
|
options: MysqlServiceOptions;
|
|
39
|
-
|
|
39
|
+
serviceStarted: boolean;
|
|
40
|
+
queries: never[];
|
|
40
41
|
constructor(options: MysqlServiceOptions);
|
|
41
42
|
static executeQuery(query: MySqlQuery | MySqlQuery[]): Promise<MysqlResult[]>;
|
|
42
43
|
init(): Promise<void>;
|
|
@@ -15,7 +15,8 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
15
15
|
reconnecting = false;
|
|
16
16
|
pool = null;
|
|
17
17
|
options;
|
|
18
|
-
|
|
18
|
+
serviceStarted = false;
|
|
19
|
+
queries = [];
|
|
19
20
|
constructor(options) {
|
|
20
21
|
super("mysql");
|
|
21
22
|
this.options = options;
|
|
@@ -23,12 +24,18 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
23
24
|
}
|
|
24
25
|
static async executeQuery(query) { return await exports.REQ_MYSQL_QUERY.request(query); }
|
|
25
26
|
async init() {
|
|
27
|
+
this.serviceStarted = false;
|
|
26
28
|
const ok = await this.createPool();
|
|
27
29
|
if (!ok) {
|
|
28
30
|
if (this.options.onLog)
|
|
29
31
|
this.options.onLog(2, "Mysql server not connected, retrying in 3 sec");
|
|
30
32
|
setTimeout(() => { this.init(); }, 3000);
|
|
31
33
|
}
|
|
34
|
+
else {
|
|
35
|
+
this.serviceStarted = true;
|
|
36
|
+
if (this.options.onLog)
|
|
37
|
+
this.options.onLog(1, "Mysql Service started!");
|
|
38
|
+
}
|
|
32
39
|
exports.REQ_MYSQL_QUERY.listener = async (data) => {
|
|
33
40
|
if (!Array.isArray(data))
|
|
34
41
|
data = [data];
|
|
@@ -98,7 +105,10 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
98
105
|
static prepareQueryFieldValue(value, system) {
|
|
99
106
|
if (!system && typeof value === "string") {
|
|
100
107
|
value = value ? value.replaceAll('"', '\\"') : null;
|
|
101
|
-
|
|
108
|
+
if (value !== null)
|
|
109
|
+
value = '"' + value + '"';
|
|
110
|
+
else
|
|
111
|
+
value = "NULL";
|
|
102
112
|
}
|
|
103
113
|
return value;
|
|
104
114
|
}
|
|
@@ -121,6 +131,10 @@ class MysqlService extends BaseService_1.BaseService {
|
|
|
121
131
|
});
|
|
122
132
|
return;
|
|
123
133
|
}
|
|
134
|
+
this.pool.on("error", (evt) => {
|
|
135
|
+
if (this.options.onLog)
|
|
136
|
+
this.options.onLog(2, `${evt}`);
|
|
137
|
+
});
|
|
124
138
|
this.pool.getConnection((err, conn) => {
|
|
125
139
|
if (err) {
|
|
126
140
|
if (this.options.onLog)
|