badmfck-api-server 2.0.8 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -45,6 +45,7 @@ export declare const REQ_HTTP_SERVER: Req<void, {
|
|
45
45
|
express: Application;
|
46
46
|
http: http.Server;
|
47
47
|
}>;
|
48
|
+
export declare const REQ_INTERNAL_CALL: Req<HTTPRequestVO, TransferPacketVO>;
|
48
49
|
export declare function Initializer(services: IBaseService[]): Promise<void>;
|
49
50
|
export declare class APIService extends BaseService {
|
50
51
|
private static nextLogID;
|
@@ -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_HTTP_SERVER = exports.REQ_HTTP_REQUESTS_COUNT = exports.REQ_HTTP_LOG = exports.REQ_CREATE_NET_LOG = exports.getDefaultOptions = void 0;
|
29
|
+
exports.APIService = exports.Initializer = exports.REQ_INTERNAL_CALL = exports.REQ_HTTP_SERVER = exports.REQ_HTTP_REQUESTS_COUNT = exports.REQ_HTTP_LOG = exports.REQ_CREATE_NET_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"));
|
@@ -68,6 +68,7 @@ exports.REQ_CREATE_NET_LOG = new badmfck_signal_1.Req(undefined, "REQ_CREATE_NET
|
|
68
68
|
exports.REQ_HTTP_LOG = new badmfck_signal_1.Req(undefined, "REQ_HTTP_LOG");
|
69
69
|
exports.REQ_HTTP_REQUESTS_COUNT = new badmfck_signal_1.Req(undefined, "REQ_HTTP_REQUESTS_COUNT");
|
70
70
|
exports.REQ_HTTP_SERVER = new badmfck_signal_1.Req(undefined, "REQ_HTTP_SERVER");
|
71
|
+
exports.REQ_INTERNAL_CALL = new badmfck_signal_1.Req(undefined, "REQ_INTERNAL_CALL");
|
71
72
|
const activeServices = [];
|
72
73
|
const entryPoints = [];
|
73
74
|
async function Initializer(services) {
|
@@ -82,7 +83,7 @@ async function Initializer(services) {
|
|
82
83
|
exports.Initializer = Initializer;
|
83
84
|
class APIService extends BaseService_1.BaseService {
|
84
85
|
static nextLogID = 0;
|
85
|
-
version = "2.0
|
86
|
+
version = "2.1.0";
|
86
87
|
options;
|
87
88
|
monitor;
|
88
89
|
monitorIndexFile;
|
@@ -127,6 +128,20 @@ class APIService extends BaseService_1.BaseService {
|
|
127
128
|
this.netLog.shift();
|
128
129
|
return log;
|
129
130
|
};
|
131
|
+
exports.REQ_INTERNAL_CALL.listener = async (req) => {
|
132
|
+
for (let i of this.options.endpoints) {
|
133
|
+
if (!i || !i.endpoints)
|
134
|
+
continue;
|
135
|
+
for (let j of i.endpoints) {
|
136
|
+
let ep = BaseEndpoint_1.BaseEndpoint.getEntryPoint() + j.endpoint;
|
137
|
+
ep = ep.replaceAll("//", "/");
|
138
|
+
if (ep === req.endpoint) {
|
139
|
+
return await i.execute(req);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
return { error: DefaultErrors_1.default.UNKNOWN_REQUEST, data: null, httpStatus: 404 };
|
144
|
+
};
|
130
145
|
const app = (0, express_1.default)();
|
131
146
|
const server = http_1.default.createServer(app);
|
132
147
|
exports.REQ_HTTP_SERVER.listener = async (ignore) => { return { express: app, http: server }; };
|