badmfck-api-server 4.0.4 → 4.0.5
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.
|
@@ -3,7 +3,7 @@ import { Application, Response } from 'express';
|
|
|
3
3
|
import { BaseService, IBaseService } from './BaseService';
|
|
4
4
|
import { IBaseEndpoint } from './BaseEndpoint';
|
|
5
5
|
import { HTTPRequestVO, IError, TransferPacketVO } from './structures/Interfaces';
|
|
6
|
-
import { Req } from "badmfck-signal";
|
|
6
|
+
import Signal, { Req } from "badmfck-signal";
|
|
7
7
|
import http from 'http';
|
|
8
8
|
export interface IMonitorUser {
|
|
9
9
|
login: string;
|
|
@@ -57,6 +57,7 @@ export declare const REQ_HTTP_SERVER: Req<void, {
|
|
|
57
57
|
export declare const REQ_INTERNAL_CALL: Req<HTTPRequestVO, IError | any>;
|
|
58
58
|
export declare const REQ_MONITOR_USERS: Req<void, IMonitorUser[]>;
|
|
59
59
|
export declare const REQ_DOC_USERS: Req<void, IMonitorUser[]>;
|
|
60
|
+
export declare const S_APP_STARTED: Signal<void>;
|
|
60
61
|
export declare function Initializer(services: IBaseService[]): Promise<void>;
|
|
61
62
|
export declare class APIService<TInterceptorResult = any, TInternalCallParams = any> extends BaseService {
|
|
62
63
|
private version;
|
|
@@ -26,13 +26,13 @@ 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.getDefaultOptions = void 0;
|
|
29
|
+
exports.APIService = exports.Initializer = exports.S_APP_STARTED = 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"));
|
|
33
33
|
const BaseEndpoint_1 = require("./BaseEndpoint");
|
|
34
34
|
const DefaultErrors_1 = __importStar(require("./structures/DefaultErrors"));
|
|
35
|
-
const badmfck_signal_1 = require("badmfck-signal");
|
|
35
|
+
const badmfck_signal_1 = __importStar(require("badmfck-signal"));
|
|
36
36
|
const LogService_1 = require("./LogService");
|
|
37
37
|
const Monitor_1 = require("./monitor/Monitor");
|
|
38
38
|
const express_fileupload_1 = __importDefault(require("express-fileupload"));
|
|
@@ -79,6 +79,7 @@ exports.REQ_HTTP_SERVER = new badmfck_signal_1.Req(undefined, "REQ_HTTP_SERVER")
|
|
|
79
79
|
exports.REQ_INTERNAL_CALL = new badmfck_signal_1.Req(undefined, "REQ_INTERNAL_CALL");
|
|
80
80
|
exports.REQ_MONITOR_USERS = new badmfck_signal_1.Req(undefined, "REQ_MONITOR_USERS");
|
|
81
81
|
exports.REQ_DOC_USERS = new badmfck_signal_1.Req(undefined, "REQ_DOC_USERS");
|
|
82
|
+
exports.S_APP_STARTED = new badmfck_signal_1.default("S_APP_STARTED");
|
|
82
83
|
const activeServices = [];
|
|
83
84
|
async function Initializer(services) {
|
|
84
85
|
services.push(new StatService_1.StatService());
|
|
@@ -87,13 +88,14 @@ async function Initializer(services) {
|
|
|
87
88
|
activeServices.push(i.getName());
|
|
88
89
|
MonitorService_1.S_STAT_REGISTRATE_SERVICE.invoke(i.getName());
|
|
89
90
|
}
|
|
91
|
+
exports.S_APP_STARTED.invoke();
|
|
90
92
|
for (let i of services) {
|
|
91
93
|
i.applicationReady();
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
exports.Initializer = Initializer;
|
|
95
97
|
class APIService extends BaseService_1.BaseService {
|
|
96
|
-
version = "4.0.
|
|
98
|
+
version = "4.0.5";
|
|
97
99
|
options;
|
|
98
100
|
monitor = null;
|
|
99
101
|
started = new Date();
|
|
@@ -335,6 +335,8 @@ class Validator {
|
|
|
335
335
|
static syncStructure(structure, node) {
|
|
336
336
|
if (structure === null || typeof structure !== "object")
|
|
337
337
|
return node;
|
|
338
|
+
if (structure && typeof structure === "object" && Object.keys(structure).length === 0)
|
|
339
|
+
return node;
|
|
338
340
|
if (Array.isArray(structure)) {
|
|
339
341
|
const tmpl = structure[0];
|
|
340
342
|
if (!Array.isArray(node) && this.isPlainObject(node)) {
|
|
@@ -380,12 +382,6 @@ class Validator {
|
|
|
380
382
|
const has = Object.prototype.hasOwnProperty.call(src, k);
|
|
381
383
|
const ov = has ? src[k] : undefined;
|
|
382
384
|
const { optional, skip_validation, default: def } = this.parseStructureOptions(k, structure);
|
|
383
|
-
const ignore = skip_validation || (this.isPlainObject(sv) && Object.keys(sv).length === 0);
|
|
384
|
-
if (ignore) {
|
|
385
|
-
if (has)
|
|
386
|
-
out[k] = ov;
|
|
387
|
-
continue;
|
|
388
|
-
}
|
|
389
385
|
if (!has) {
|
|
390
386
|
if (sv && typeof sv === "object") {
|
|
391
387
|
out[k] = this.syncStructure(sv, this.clone(sv));
|