badmfck-api-server 1.1.7 → 1.1.8
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.
@@ -16,7 +16,6 @@ function getDefaultOptions() {
|
|
16
16
|
baseEndPoint: '/api/',
|
17
17
|
corsHostWhiteList: [
|
18
18
|
'http://localhost:3000',
|
19
|
-
'http://localhost:8091',
|
20
19
|
],
|
21
20
|
endpoints: [],
|
22
21
|
jsonLimit: "10mb",
|
@@ -49,6 +48,11 @@ class APIService extends BaseService_1.BaseService {
|
|
49
48
|
constructor(options) {
|
50
49
|
super('HTTP Service');
|
51
50
|
this.options = options ?? getDefaultOptions();
|
51
|
+
if (!this.options.corsHostWhiteList)
|
52
|
+
this.options.corsHostWhiteList = [];
|
53
|
+
const self = "http://localhost:" + this.options.port;
|
54
|
+
if (!this.options.corsHostWhiteList.find(val => val === self))
|
55
|
+
this.options.corsHostWhiteList.push();
|
52
56
|
}
|
53
57
|
async init() {
|
54
58
|
exports.REQ_HTTP_LOG.listener = async (ignore) => this.netLog;
|
@@ -26,7 +26,8 @@ class MysqlService extends BaseService_1.BaseService {
|
|
26
26
|
const ok = await this.createPool();
|
27
27
|
if (!ok) {
|
28
28
|
if (this.options.onLog)
|
29
|
-
this.options.onLog(2, "Mysql server not connected");
|
29
|
+
this.options.onLog(2, "Mysql server not connected, retrying in 3 sec");
|
30
|
+
setTimeout(() => { this.init(); }, 3000);
|
30
31
|
}
|
31
32
|
exports.REQ_MYSQL_QUERY.listener = async (data) => {
|
32
33
|
if (!Array.isArray(data))
|
@@ -72,7 +73,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
72
73
|
oninsertNames.push(i.name);
|
73
74
|
oninsertValues.push(i._parsedValue);
|
74
75
|
}
|
75
|
-
query = query.replaceAll("@
|
76
|
+
query = query.replaceAll("@insert", `(${oninsertNames.join(",")}) VALUES (${oninsertValues.join(",")})`);
|
76
77
|
}
|
77
78
|
if (query.indexOf("@onupdate") !== -1) {
|
78
79
|
let onUpdate = [];
|
@@ -132,6 +133,8 @@ class MysqlService extends BaseService_1.BaseService {
|
|
132
133
|
return;
|
133
134
|
}
|
134
135
|
if (!conn) {
|
136
|
+
if (this.options.onLog)
|
137
|
+
this.options.onLog(2, `NO_CONN`);
|
135
138
|
resolve({
|
136
139
|
error: {
|
137
140
|
code: "NO_CONN",
|
@@ -154,6 +157,8 @@ class MysqlService extends BaseService_1.BaseService {
|
|
154
157
|
conn.release();
|
155
158
|
}
|
156
159
|
catch (e) { }
|
160
|
+
if (this.options.onLog)
|
161
|
+
this.options.onLog(2, "QUERY_ERR " + e);
|
157
162
|
resolve({
|
158
163
|
error: {
|
159
164
|
code: "QUERY_ERR",
|
@@ -239,6 +244,7 @@ class MysqlService extends BaseService_1.BaseService {
|
|
239
244
|
this.options.onLog(2, "Can't connect to MYSQL!");
|
240
245
|
err = true;
|
241
246
|
}
|
247
|
+
2;
|
242
248
|
return new Promise((res, rej) => {
|
243
249
|
if (err) {
|
244
250
|
res(false);
|