badmfck-api-server 4.1.6 → 4.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.
- package/dist/apiServer/APIService.js +29 -18
- package/package.json +1 -1
|
@@ -39,6 +39,7 @@ const express_fileupload_1 = __importDefault(require("express-fileupload"));
|
|
|
39
39
|
const Liveness_1 = require("./routes/Liveness");
|
|
40
40
|
const Readiness_1 = require("./routes/Readiness");
|
|
41
41
|
const http_1 = __importDefault(require("http"));
|
|
42
|
+
const path_1 = __importDefault(require("path"));
|
|
42
43
|
const StatService_1 = require("./StatService");
|
|
43
44
|
const ExternalServiceEndpoint_1 = require("./external/ExternalServiceEndpoint");
|
|
44
45
|
const MonitorService_1 = require("./MonitorService");
|
|
@@ -97,7 +98,7 @@ async function Initializer(services) {
|
|
|
97
98
|
}
|
|
98
99
|
exports.Initializer = Initializer;
|
|
99
100
|
class APIService extends BaseService_1.BaseService {
|
|
100
|
-
version = "4.1.
|
|
101
|
+
version = "4.1.07";
|
|
101
102
|
options;
|
|
102
103
|
monitor = null;
|
|
103
104
|
started = new Date();
|
|
@@ -485,26 +486,36 @@ class APIService extends BaseService_1.BaseService {
|
|
|
485
486
|
else {
|
|
486
487
|
try {
|
|
487
488
|
if (data.file) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
else {
|
|
496
|
-
try {
|
|
497
|
-
res.destroy?.(err);
|
|
498
|
-
}
|
|
499
|
-
catch { }
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
489
|
+
const normalizedFile = process.platform === "win32" ? data.file : data.file.replaceAll("\\", "/");
|
|
490
|
+
const filePath = path_1.default.isAbsolute(normalizedFile) ? normalizedFile : path_1.default.resolve(normalizedFile);
|
|
491
|
+
const onSendFileError = (err) => {
|
|
492
|
+
(0, LogService_1.logError)("Can't send file: " + filePath);
|
|
493
|
+
if (!res.headersSent && !res.writableEnded) {
|
|
494
|
+
res.status(500).send({ error: DefaultErrors_1.default.CANT_SEND_FILE, data: null });
|
|
495
|
+
return;
|
|
502
496
|
}
|
|
503
497
|
else {
|
|
504
|
-
|
|
505
|
-
|
|
498
|
+
try {
|
|
499
|
+
res.destroy?.(err);
|
|
500
|
+
}
|
|
501
|
+
catch { }
|
|
502
|
+
return;
|
|
506
503
|
}
|
|
507
|
-
}
|
|
504
|
+
};
|
|
505
|
+
try {
|
|
506
|
+
res.sendFile(filePath, err => {
|
|
507
|
+
if (err) {
|
|
508
|
+
onSendFileError(err);
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
if (req && !data.ignoreHttpLogging)
|
|
512
|
+
this.addNetlog(data, req, requestTime, 0);
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
catch (e) {
|
|
517
|
+
onSendFileError(e);
|
|
518
|
+
}
|
|
508
519
|
return;
|
|
509
520
|
}
|
|
510
521
|
if (data.redirect) {
|