badmfck-api-server 1.7.1 → 1.7.3
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.
@@ -60,7 +60,9 @@ class BaseEndpoint {
|
|
60
60
|
async execute(req) {
|
61
61
|
if (this.endpoints && this.endpoints.length > 0) {
|
62
62
|
for (let i of this.endpoints) {
|
63
|
-
|
63
|
+
let targetEP = BaseEndpoint.entrypoint + i.endpoint;
|
64
|
+
targetEP = targetEP.replaceAll("//", "/");
|
65
|
+
if (targetEP === req.endpoint && i.handler && typeof i.handler === "function")
|
64
66
|
return i.handler.call(this, req);
|
65
67
|
}
|
66
68
|
}
|
@@ -1,8 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isError = void 0;
|
4
|
+
const Validator_1 = require("../helper/Validator");
|
3
5
|
class DefaultErrors {
|
4
6
|
static NOT_IMPLEMENTED = { code: 1, message: "Not implemented" };
|
5
7
|
static UNKNOWN_REQUEST = { code: 2, message: "Unknown request" };
|
6
8
|
static JSON_MALFORMED = { code: 3, message: "JSON malformed" };
|
7
9
|
}
|
10
|
+
const isError = (obj) => {
|
11
|
+
const isFieldsExists = Validator_1.Validator.validateObject(['code', 'message'], obj);
|
12
|
+
if (!isFieldsExists)
|
13
|
+
return false;
|
14
|
+
if (Validator_1.Validator.validateValue("code", { type: "number" }) !== Validator_1.ValidationReport.OK)
|
15
|
+
return false;
|
16
|
+
if (Validator_1.Validator.validateValue("message", { type: "string" }) !== Validator_1.ValidationReport.OK)
|
17
|
+
return false;
|
18
|
+
return true;
|
19
|
+
};
|
20
|
+
exports.isError = isError;
|
8
21
|
exports.default = DefaultErrors;
|