badmfck-api-server 1.1.3 → 1.1.5
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.
@@ -43,7 +43,7 @@ async function Initializer(services) {
|
|
43
43
|
exports.Initializer = Initializer;
|
44
44
|
class APIService extends BaseService_1.BaseService {
|
45
45
|
static nextLogID = 0;
|
46
|
-
version = "1.2.
|
46
|
+
version = "1.2.2";
|
47
47
|
options;
|
48
48
|
netLog = [];
|
49
49
|
constructor(options) {
|
@@ -128,7 +128,20 @@ class APIService extends BaseService_1.BaseService {
|
|
128
128
|
headers: req.headers,
|
129
129
|
endpoint: ep
|
130
130
|
};
|
131
|
-
|
131
|
+
let result;
|
132
|
+
try {
|
133
|
+
result = await i.execute(httpRequest);
|
134
|
+
}
|
135
|
+
catch (e) {
|
136
|
+
this.sendResponse(res, {
|
137
|
+
httpStatus: 500,
|
138
|
+
error: {
|
139
|
+
code: 10002,
|
140
|
+
message: "Internal server error"
|
141
|
+
}
|
142
|
+
}, tme, ep, log);
|
143
|
+
return;
|
144
|
+
}
|
132
145
|
this.sendResponse(res, result, tme, ep, log);
|
133
146
|
};
|
134
147
|
execute();
|
@@ -167,6 +180,10 @@ class APIService extends BaseService_1.BaseService {
|
|
167
180
|
log.response = { redirect: data.redirect };
|
168
181
|
}
|
169
182
|
else {
|
183
|
+
if (data.headers) {
|
184
|
+
for (let i in data.headers)
|
185
|
+
res.setHeader(i, data.headers[i]);
|
186
|
+
}
|
170
187
|
res.statusCode = data.httpStatus ?? 200;
|
171
188
|
if (data.rawResponse) {
|
172
189
|
res.send(data.data);
|
@@ -63,6 +63,17 @@ class MysqlService extends BaseService_1.BaseService {
|
|
63
63
|
.replaceAll('@fields', insertFieldNames.join(","))
|
64
64
|
.replaceAll('@values', insertFieldValues.join(","));
|
65
65
|
}
|
66
|
+
if (query.indexOf("@insert") !== -1) {
|
67
|
+
let oninsertNames = [];
|
68
|
+
let oninsertValues = [];
|
69
|
+
for (let i of fields) {
|
70
|
+
if (i.ignoreInInsert)
|
71
|
+
continue;
|
72
|
+
oninsertNames.push(i.name);
|
73
|
+
oninsertValues.push(i._parsedValue);
|
74
|
+
}
|
75
|
+
query = query.replaceAll("@oninsert", `(${oninsertNames.join(",")}) VALUES (${oninsertValues.join(",")})`);
|
76
|
+
}
|
66
77
|
if (query.indexOf("@onupdate") !== -1) {
|
67
78
|
let onUpdate = [];
|
68
79
|
for (let i of fields) {
|