badmfck-api-server 1.7.3 → 1.7.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,5 +4,8 @@ declare class DefaultErrors {
|
|
4
4
|
static UNKNOWN_REQUEST: IError;
|
5
5
|
static JSON_MALFORMED: IError;
|
6
6
|
}
|
7
|
-
export declare
|
7
|
+
export declare class ErrorUtils {
|
8
|
+
static isError(obj: any): boolean;
|
9
|
+
static appendStack(error: IError, stack?: IError[]): IError;
|
10
|
+
}
|
8
11
|
export default DefaultErrors;
|
@@ -1,21 +1,27 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.ErrorUtils = void 0;
|
4
4
|
const Validator_1 = require("../helper/Validator");
|
5
5
|
class DefaultErrors {
|
6
6
|
static NOT_IMPLEMENTED = { code: 1, message: "Not implemented" };
|
7
7
|
static UNKNOWN_REQUEST = { code: 2, message: "Unknown request" };
|
8
8
|
static JSON_MALFORMED = { code: 3, message: "JSON malformed" };
|
9
9
|
}
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
class ErrorUtils {
|
11
|
+
static isError(obj) {
|
12
|
+
const isFieldsExists = Validator_1.Validator.validateObject(['code', 'message'], obj);
|
13
|
+
if (!isFieldsExists)
|
14
|
+
return false;
|
15
|
+
if (Validator_1.Validator.validateValue("code", { type: "number" }) !== Validator_1.ValidationReport.OK)
|
16
|
+
return false;
|
17
|
+
if (Validator_1.Validator.validateValue("message", { type: "string" }) !== Validator_1.ValidationReport.OK)
|
18
|
+
return false;
|
19
|
+
return true;
|
20
|
+
}
|
21
|
+
static appendStack(error, stack) {
|
22
|
+
error.stack = stack;
|
23
|
+
return error;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
exports.ErrorUtils = ErrorUtils;
|
21
27
|
exports.default = DefaultErrors;
|
package/dist/index.d.ts
CHANGED
@@ -3,6 +3,7 @@ import { LocalRequest } from "./apiServer/LocalRequest";
|
|
3
3
|
import { MysqlService } from "./apiServer/MysqlService";
|
4
4
|
import { Validator } from "./apiServer/helper/Validator";
|
5
5
|
import { LogService } from "./apiServer/LogService";
|
6
|
+
import { ErrorUtils } from "./apiServer/structures/DefaultErrors";
|
6
7
|
import { S_MONITOR_REGISTRATE_ACTION } from "./apiServer/monitor/Monitor";
|
7
8
|
import { DataProvider } from "./apiServer/helper/DataProvider";
|
8
|
-
export { APIService, Initializer, LocalRequest, MysqlService, Validator, LogService, DataProvider, S_MONITOR_REGISTRATE_ACTION };
|
9
|
+
export { APIService, Initializer, LocalRequest, MysqlService, Validator, LogService, DataProvider, ErrorUtils, S_MONITOR_REGISTRATE_ACTION };
|
package/dist/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.S_MONITOR_REGISTRATE_ACTION = exports.DataProvider = exports.LogService = exports.Validator = exports.MysqlService = exports.LocalRequest = exports.Initializer = exports.APIService = void 0;
|
3
|
+
exports.S_MONITOR_REGISTRATE_ACTION = exports.ErrorUtils = exports.DataProvider = exports.LogService = exports.Validator = exports.MysqlService = exports.LocalRequest = exports.Initializer = exports.APIService = void 0;
|
4
4
|
const APIService_1 = require("./apiServer/APIService");
|
5
5
|
Object.defineProperty(exports, "APIService", { enumerable: true, get: function () { return APIService_1.APIService; } });
|
6
6
|
Object.defineProperty(exports, "Initializer", { enumerable: true, get: function () { return APIService_1.Initializer; } });
|
@@ -12,6 +12,8 @@ const Validator_1 = require("./apiServer/helper/Validator");
|
|
12
12
|
Object.defineProperty(exports, "Validator", { enumerable: true, get: function () { return Validator_1.Validator; } });
|
13
13
|
const LogService_1 = require("./apiServer/LogService");
|
14
14
|
Object.defineProperty(exports, "LogService", { enumerable: true, get: function () { return LogService_1.LogService; } });
|
15
|
+
const DefaultErrors_1 = require("./apiServer/structures/DefaultErrors");
|
16
|
+
Object.defineProperty(exports, "ErrorUtils", { enumerable: true, get: function () { return DefaultErrors_1.ErrorUtils; } });
|
15
17
|
const Monitor_1 = require("./apiServer/monitor/Monitor");
|
16
18
|
Object.defineProperty(exports, "S_MONITOR_REGISTRATE_ACTION", { enumerable: true, get: function () { return Monitor_1.S_MONITOR_REGISTRATE_ACTION; } });
|
17
19
|
const DataProvider_1 = require("./apiServer/helper/DataProvider");
|