badmfck-api-server 2.9.0 → 2.9.2
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.
@@ -1,17 +1,13 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.BaseService = void 0;
|
7
|
-
const
|
8
|
-
const finalize = new badmfck_signal_1.default();
|
4
|
+
const finalize = [];
|
9
5
|
process.on('SIGINT', async () => {
|
10
|
-
finalize.
|
6
|
+
await Promise.all(finalize.map(f => f()));
|
11
7
|
process.exit(0);
|
12
8
|
});
|
13
9
|
process.on('SIGTERM', async () => {
|
14
|
-
finalize.
|
10
|
+
await Promise.all(finalize.map(f => f()));
|
15
11
|
process.exit(0);
|
16
12
|
});
|
17
13
|
class BaseService {
|
@@ -21,10 +17,10 @@ class BaseService {
|
|
21
17
|
}
|
22
18
|
async init() {
|
23
19
|
console.log("Service: " + this.name + " initialized");
|
24
|
-
finalize.
|
20
|
+
finalize.push(this.finishService);
|
25
21
|
}
|
26
22
|
async finishService() {
|
27
|
-
console.log("
|
23
|
+
console.log("finishService -> " + this.name);
|
28
24
|
}
|
29
25
|
getName() {
|
30
26
|
return this.name;
|
@@ -292,9 +292,10 @@ class MysqlAdapter {
|
|
292
292
|
let f = fields[i];
|
293
293
|
if (f.ignoreInInsert)
|
294
294
|
continue;
|
295
|
-
|
296
|
-
|
297
|
-
|
295
|
+
let name = f.name;
|
296
|
+
if (!name)
|
297
|
+
name = i.replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "");
|
298
|
+
insertFieldNames.push('`' + (name + "").replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "") + '`');
|
298
299
|
insertFieldValues.push(f._parsedValue);
|
299
300
|
}
|
300
301
|
query = query
|
@@ -308,7 +309,10 @@ class MysqlAdapter {
|
|
308
309
|
let f = fields[i];
|
309
310
|
if (f.ignoreInInsert)
|
310
311
|
continue;
|
311
|
-
|
312
|
+
let name = f.name;
|
313
|
+
if (!name)
|
314
|
+
name = i.replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "");
|
315
|
+
oninsertNames.push(name);
|
312
316
|
oninsertValues.push(f._parsedValue);
|
313
317
|
}
|
314
318
|
query = query.replaceAll("@insert", `(${oninsertNames.join(",")}) VALUES (${oninsertValues.join(",")})`);
|
@@ -319,7 +323,10 @@ class MysqlAdapter {
|
|
319
323
|
let f = fields[i];
|
320
324
|
if (f.ignoreInUpdate)
|
321
325
|
continue;
|
322
|
-
|
326
|
+
let name = f.name;
|
327
|
+
if (!name)
|
328
|
+
name = i.replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "");
|
329
|
+
onUpdate.push('`' + (name + "") + '` = ' + f._parsedValue);
|
323
330
|
}
|
324
331
|
query = query.replaceAll("@onupdate", onUpdate.join(" , "));
|
325
332
|
}
|
@@ -329,7 +336,10 @@ class MysqlAdapter {
|
|
329
336
|
let f = fields[i];
|
330
337
|
if (!f.useInReplace)
|
331
338
|
continue;
|
332
|
-
|
339
|
+
let name = f.name;
|
340
|
+
if (!name)
|
341
|
+
name = i.replaceAll("`", '').replaceAll('\"', "").replaceAll('\'', "");
|
342
|
+
onDuplicate.push('`' + (name + "") + f._parsedValue);
|
333
343
|
}
|
334
344
|
query = query.replaceAll("@onduplicate", onDuplicate.join(" , "));
|
335
345
|
}
|