badmfck-api-server 4.0.62 → 4.0.64
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.
- package/dist/apiServer/APIService.js +1 -1
- package/dist/apiServer/DBService.d.ts +1 -0
- package/dist/apiServer/db/MysqlAdapter.js +15 -1
- package/dist/apiServer/documentation/Documentation.js +1 -1
- package/dist/apiServer/external/MicroserviceClient.js +1 -0
- package/dist/apiServer/external/MicroserviceHostController.js +1 -1
- package/package.json +1 -1
|
@@ -445,8 +445,21 @@ class MysqlAdapter {
|
|
|
445
445
|
let result = null;
|
|
446
446
|
if (this.options.maxQueryTimeout && this.options.maxQueryTimeout > 0)
|
|
447
447
|
result = await this.withTimeout(conn.query(query), this.options.maxQueryTimeout, query);
|
|
448
|
-
else
|
|
448
|
+
else {
|
|
449
449
|
result = await conn.query(query);
|
|
450
|
+
}
|
|
451
|
+
let total = null;
|
|
452
|
+
;
|
|
453
|
+
if (request.calculateCount) {
|
|
454
|
+
const cres = await conn.query("SELECT FOUND_ROWS() as total");
|
|
455
|
+
if (cres && cres[0]) {
|
|
456
|
+
const res = cres[0];
|
|
457
|
+
if (Array.isArray(res) && res.length > 0 && "total" in res[0])
|
|
458
|
+
total = res[0].total;
|
|
459
|
+
else if ("total" in res)
|
|
460
|
+
total = res.total;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
450
463
|
this.lastSuccessQueryTime = +new Date();
|
|
451
464
|
if (!request.transactionID && doCloseConnection)
|
|
452
465
|
this.finalizeConnection(conn);
|
|
@@ -455,6 +468,7 @@ class MysqlAdapter {
|
|
|
455
468
|
return {
|
|
456
469
|
data: result[0],
|
|
457
470
|
error: null,
|
|
471
|
+
total: total ? total : undefined,
|
|
458
472
|
execution: {
|
|
459
473
|
started_at: executionStartTime,
|
|
460
474
|
finished_at: Date.now()
|
|
@@ -70,7 +70,7 @@ class Documentation extends BaseEndpoint_1.BaseEndpoint {
|
|
|
70
70
|
async checkAuthorization(req) {
|
|
71
71
|
const users = await APIService_1.REQ_DOC_USERS.request();
|
|
72
72
|
if (!users || users.length == 0)
|
|
73
|
-
throw { ...DefaultErrors_1.default.UNAUTHORIZED, details: "No users found for documentation access" };
|
|
73
|
+
throw { ...DefaultErrors_1.default.UNAUTHORIZED, details: "No users found for documentation access, please set up users first." };
|
|
74
74
|
let header = req.headers['authorization'];
|
|
75
75
|
if (!header)
|
|
76
76
|
throw { ...DefaultErrors_1.default.UNAUTHORIZED, details: "No authorization header found" };
|
|
@@ -38,6 +38,7 @@ class MicroserviceClient extends BaseService_1.BaseService {
|
|
|
38
38
|
const nonce = crypto_1.default.randomBytes(16).toString("hex");
|
|
39
39
|
const headers = {
|
|
40
40
|
"Content-Type": "application/json",
|
|
41
|
+
"x-microservice-id": this.options.id,
|
|
41
42
|
"x-microservice-ts": ts,
|
|
42
43
|
"x-microservice-nonce": nonce
|
|
43
44
|
};
|
|
@@ -45,7 +45,7 @@ class MicroserviceHostController extends BaseEndpoint_1.BaseEndpoint {
|
|
|
45
45
|
throw DefaultErrors_1.default.METHOD_NOT_ALLOWED;
|
|
46
46
|
const microserviceHost = MicroserviceHost_1.MicroserviceHost.getMicroservice(req.headers["x-microservice-id"]);
|
|
47
47
|
if (!microserviceHost)
|
|
48
|
-
throw { ...DefaultErrors_1.default.NOT_FOUND, message: "Microservice host not found" };
|
|
48
|
+
throw { ...DefaultErrors_1.default.NOT_FOUND, message: "Microservice host not found with id: " + req.headers["x-microservice-id"] };
|
|
49
49
|
const result = await microserviceHost.handleIncomingRequest(req);
|
|
50
50
|
if (DefaultErrors_1.ErrorUtils.isError(result))
|
|
51
51
|
throw result;
|