badmfck-api-server 2.1.1 → 2.1.2
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.
@@ -83,7 +83,7 @@ async function Initializer(services) {
|
|
83
83
|
exports.Initializer = Initializer;
|
84
84
|
class APIService extends BaseService_1.BaseService {
|
85
85
|
static nextLogID = 0;
|
86
|
-
version = "2.1.
|
86
|
+
version = "2.1.2";
|
87
87
|
options;
|
88
88
|
monitor;
|
89
89
|
monitorIndexFile;
|
@@ -365,6 +365,24 @@ class APIService extends BaseService_1.BaseService {
|
|
365
365
|
}
|
366
366
|
else {
|
367
367
|
try {
|
368
|
+
if (data.file) {
|
369
|
+
res.sendFile(data.file, err => {
|
370
|
+
if (err) {
|
371
|
+
if (log)
|
372
|
+
log.error = "Can't send file: " + data.file;
|
373
|
+
if (this.options.onError)
|
374
|
+
this.options.onError("Can't send file: " + data.file, err);
|
375
|
+
if (this.monitor && data.endpoint)
|
376
|
+
this.monitor.registrateAPIError(data.endpoint);
|
377
|
+
this.sendResponse(res, {
|
378
|
+
error: DefaultErrors_1.default.CANT_SEND_FILE,
|
379
|
+
data: null,
|
380
|
+
httpStatus: 500
|
381
|
+
}, requestTime, data.endpoint);
|
382
|
+
}
|
383
|
+
});
|
384
|
+
return;
|
385
|
+
}
|
368
386
|
if (data.redirect) {
|
369
387
|
res.redirect(data.redirect);
|
370
388
|
if (log)
|
@@ -4,6 +4,8 @@ declare class DefaultErrors {
|
|
4
4
|
static UNKNOWN_REQUEST: IError;
|
5
5
|
static JSON_MALFORMED: IError;
|
6
6
|
static FILE_TOO_LARGE: IError;
|
7
|
+
static CANT_SEND_FILE: IError;
|
8
|
+
static FILE_NOT_EXISTS: IError;
|
7
9
|
}
|
8
10
|
export declare class ErrorUtils {
|
9
11
|
static isError(obj: any): boolean;
|
@@ -7,6 +7,8 @@ class DefaultErrors {
|
|
7
7
|
static UNKNOWN_REQUEST = { code: 2, message: "Unknown request" };
|
8
8
|
static JSON_MALFORMED = { code: 3, message: "JSON malformed" };
|
9
9
|
static FILE_TOO_LARGE = { code: 4, message: "File is too large" };
|
10
|
+
static CANT_SEND_FILE = { code: 5, message: "Can't send file" };
|
11
|
+
static FILE_NOT_EXISTS = { code: 5, message: "File not exists" };
|
10
12
|
}
|
11
13
|
class ErrorUtils {
|
12
14
|
static isError(obj) {
|