badmfck-api-server 3.6.2 → 3.6.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.
@@ -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.4";
|
99
99
|
options;
|
100
100
|
monitor = null;
|
101
101
|
started = new Date();
|
@@ -303,7 +303,20 @@ class APIService extends BaseService_1.BaseService {
|
|
303
303
|
result = await i.__execute(httpRequest);
|
304
304
|
}
|
305
305
|
catch (e) {
|
306
|
-
|
306
|
+
console.error(e);
|
307
|
+
let stack = "";
|
308
|
+
let message = "";
|
309
|
+
if (e instanceof Error) {
|
310
|
+
stack = e.stack ?? "no-stack";
|
311
|
+
message = e.message;
|
312
|
+
(0, LogService_1.logCrit)('${APIService.js}', JSON.stringify({
|
313
|
+
stack: stack,
|
314
|
+
message: message
|
315
|
+
}));
|
316
|
+
}
|
317
|
+
if (DefaultErrors_1.ErrorUtils.isError(e)) {
|
318
|
+
(0, LogService_1.logCrit)('${APIService.js}', JSON.stringify(e));
|
319
|
+
}
|
307
320
|
let data = {
|
308
321
|
error: {
|
309
322
|
code: 10002,
|
@@ -371,6 +384,8 @@ class APIService extends BaseService_1.BaseService {
|
|
371
384
|
if (res.destroyed || res.closed) {
|
372
385
|
if (log)
|
373
386
|
log.error = "Connection already closed, can't send response for: " + data.endpoint;
|
387
|
+
if (this.options.onError)
|
388
|
+
this.options.onError("Connection already closed, can't send response: " + data.endpoint, data);
|
374
389
|
}
|
375
390
|
else {
|
376
391
|
try {
|
@@ -472,8 +472,18 @@ class MysqlAdapter {
|
|
472
472
|
let system = field.system;
|
473
473
|
if (value === null || value === undefined)
|
474
474
|
return "NULL";
|
475
|
-
if (!system && typeof value === "
|
476
|
-
|
475
|
+
if (!system && typeof value === "object") {
|
476
|
+
try {
|
477
|
+
value = JSON.stringify(value);
|
478
|
+
}
|
479
|
+
catch (e) {
|
480
|
+
console.error("Can't prepare JSON object", e);
|
481
|
+
value = "{}";
|
482
|
+
}
|
483
|
+
}
|
484
|
+
if (!system && typeof value === "string") {
|
485
|
+
value = promise_1.default.escape(value);
|
486
|
+
}
|
477
487
|
if (typeof value === "boolean")
|
478
488
|
value = value ? 1 : 0;
|
479
489
|
field.__parsedValue = value;
|