badmfck-api-server 3.9.87 → 3.9.89
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.d.ts +0 -1
- package/dist/apiServer/APIService.js +1 -2
- package/dist/apiServer/BaseEndpoint.js +2 -2
- package/dist/apiServer/helper/Validator.js +4 -2
- package/dist/apiServer/structures/DefaultErrors.d.ts +4 -3
- package/dist/apiServer/structures/DefaultErrors.js +5 -4
- package/package.json +1 -1
@@ -48,7 +48,6 @@ type InferInterceptor<T> = T extends IInterceptor<infer U> ? U : unknown;
|
|
48
48
|
export declare const getDefaultOptions: <I extends IInterceptor<any> | undefined>(overrides?: (Omit<Partial<APIServiceOptions<InferInterceptor<NonNullable<I>>>>, "interceptor"> & {
|
49
49
|
interceptor?: I | undefined;
|
50
50
|
}) | undefined) => APIServiceOptions<InferInterceptor<NonNullable<I>>>;
|
51
|
-
export declare const REQ_DEPREACTED_CREATE_NET_LOG: Req<void, APIServiceNetworkLogItem>;
|
52
51
|
export declare const REQ_HTTP_LOG: Req<void, APIServiceNetworkLogItem[]>;
|
53
52
|
export declare const REQ_HTTP_REQUESTS_COUNT: Req<void, number>;
|
54
53
|
export declare const REQ_HTTP_SERVER: Req<void, {
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.APIService = exports.Initializer = exports.REQ_DOC_USERS = exports.REQ_MONITOR_USERS = exports.REQ_INTERNAL_CALL = exports.REQ_HTTP_SERVER = exports.REQ_HTTP_REQUESTS_COUNT = exports.REQ_HTTP_LOG = exports.
|
29
|
+
exports.APIService = exports.Initializer = exports.REQ_DOC_USERS = exports.REQ_MONITOR_USERS = exports.REQ_INTERNAL_CALL = exports.REQ_HTTP_SERVER = exports.REQ_HTTP_REQUESTS_COUNT = exports.REQ_HTTP_LOG = exports.getDefaultOptions = void 0;
|
30
30
|
const express_1 = __importDefault(require("express"));
|
31
31
|
const BaseService_1 = require("./BaseService");
|
32
32
|
const cors_1 = __importDefault(require("cors"));
|
@@ -72,7 +72,6 @@ const getDefaultOptions = (overrides) => {
|
|
72
72
|
return { ...base, ...overrides };
|
73
73
|
};
|
74
74
|
exports.getDefaultOptions = getDefaultOptions;
|
75
|
-
exports.REQ_DEPREACTED_CREATE_NET_LOG = new badmfck_signal_1.Req(undefined, "REQ_CREATE_NET_LOG");
|
76
75
|
exports.REQ_HTTP_LOG = new badmfck_signal_1.Req(undefined, "REQ_HTTP_LOG");
|
77
76
|
exports.REQ_HTTP_REQUESTS_COUNT = new badmfck_signal_1.Req(undefined, "REQ_HTTP_REQUESTS_COUNT");
|
78
77
|
exports.REQ_HTTP_SERVER = new badmfck_signal_1.Req(undefined, "REQ_HTTP_SERVER");
|
@@ -122,10 +122,10 @@ class BaseEndpoint {
|
|
122
122
|
if (!structure)
|
123
123
|
return;
|
124
124
|
if (typeof structure === "object" && (!req.data || typeof req.data !== "object"))
|
125
|
-
throw { ...DefaultErrors_1.default.
|
125
|
+
throw { ...DefaultErrors_1.default.WRONG_PARAMS, details: "empty or invalid request" };
|
126
126
|
const report = await Validator_1.Validator.validateStructure(structure, req.data);
|
127
127
|
if (report)
|
128
|
-
throw { ...DefaultErrors_1.default.
|
128
|
+
throw { ...DefaultErrors_1.default.WRONG_PARAMS, details: report };
|
129
129
|
Validator_1.Validator.filterStructure(structure, req.data);
|
130
130
|
}
|
131
131
|
createStream(req) {
|
@@ -188,8 +188,10 @@ class Validator {
|
|
188
188
|
if (!structureOptions.values.includes(object[i])) {
|
189
189
|
let caseValue = null;
|
190
190
|
for (let i of structureOptions.values) {
|
191
|
-
|
192
|
-
|
191
|
+
if (i === null || i === undefined)
|
192
|
+
continue;
|
193
|
+
const v = (i + "").toLowerCase().trim();
|
194
|
+
if (v === (object[i] + "").toLowerCase().trim()) {
|
193
195
|
caseValue = object[i];
|
194
196
|
break;
|
195
197
|
}
|
@@ -15,15 +15,16 @@ declare class DefaultErrors {
|
|
15
15
|
static FORBIDDEN: IError;
|
16
16
|
static NOT_FOUND: IError;
|
17
17
|
static INTERNAL_SERVER_ERROR: IError;
|
18
|
-
static EXTERNAL_SERVICE_ERROR: IError;
|
19
|
-
static MAINTENANCE_MODE: IError;
|
20
|
-
static CONFLICT: IError;
|
21
18
|
static INVALID_TOKEN: IError;
|
22
19
|
static INVALID_CREDENTIALS: IError;
|
23
20
|
static INVALID_DATA: IError;
|
24
21
|
static INVALID_FILE: IError;
|
22
|
+
static EXTERNAL_SERVICE_ERROR: IError;
|
23
|
+
static MAINTENANCE_MODE: IError;
|
24
|
+
static CONFLICT: IError;
|
25
25
|
static WRONG_DATA_TYPE: IError;
|
26
26
|
static UPROCESSIABLE_CONTENT: IError;
|
27
|
+
static WRONG_PARAMS: IError;
|
27
28
|
}
|
28
29
|
export declare class ErrorUtils {
|
29
30
|
static isError(obj: any): obj is IError;
|
@@ -18,15 +18,16 @@ class DefaultErrors {
|
|
18
18
|
static FORBIDDEN = { code: 12, message: "Forbidden", httpStatus: 403 };
|
19
19
|
static NOT_FOUND = { code: 13, message: "Not found", httpStatus: 404 };
|
20
20
|
static INTERNAL_SERVER_ERROR = { code: 14, message: "Internal server error.", httpStatus: 500 };
|
21
|
-
static EXTERNAL_SERVICE_ERROR = { code: 19, message: "External service error", httpStatus: 502 };
|
22
|
-
static MAINTENANCE_MODE = { code: 21, message: "Service in maintenance mode", httpStatus: 503 };
|
23
|
-
static CONFLICT = { code: 22, message: "Conflict", httpStatus: 409 };
|
24
21
|
static INVALID_TOKEN = { code: 15, message: "Invalid token", httpStatus: 401 };
|
25
22
|
static INVALID_CREDENTIALS = { code: 16, message: "Invalid credentials", httpStatus: 401 };
|
26
23
|
static INVALID_DATA = { code: 17, message: "Invalid data", httpStatus: 422 };
|
27
24
|
static INVALID_FILE = { code: 18, message: "Invalid file", httpStatus: 422 };
|
25
|
+
static EXTERNAL_SERVICE_ERROR = { code: 19, message: "External service error", httpStatus: 502 };
|
26
|
+
static MAINTENANCE_MODE = { code: 21, message: "Service in maintenance mode", httpStatus: 503 };
|
27
|
+
static CONFLICT = { code: 22, message: "Conflict", httpStatus: 409 };
|
28
28
|
static WRONG_DATA_TYPE = { code: 23, message: "Wrong data type", httpStatus: 422 };
|
29
|
-
static UPROCESSIABLE_CONTENT = { code:
|
29
|
+
static UPROCESSIABLE_CONTENT = { code: 24, message: "Unprocessable content", httpStatus: 422 };
|
30
|
+
static WRONG_PARAMS = { code: 25, message: "Wrong params", httpStatus: 400 };
|
30
31
|
}
|
31
32
|
class ErrorUtils {
|
32
33
|
static isError(obj) {
|