badmfck-api-server 1.9.5 → 1.9.6
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.
@@ -1,8 +1,10 @@
|
|
1
|
+
/// <reference types="node" />
|
1
2
|
import { Application, Response } from 'express';
|
2
3
|
import { BaseService, IBaseService } from './BaseService';
|
3
4
|
import { IBaseEndpoint } from './BaseEndpoint';
|
4
5
|
import { HTTPRequestVO, TransferPacketVO } from './structures/Interfaces';
|
5
6
|
import { Req } from "badmfck-signal";
|
7
|
+
import http from 'http';
|
6
8
|
export interface APIServiceNetworkLogItem {
|
7
9
|
id: number;
|
8
10
|
created: number;
|
@@ -39,7 +41,10 @@ export declare function getDefaultOptions(): APIServiceOptions;
|
|
39
41
|
export declare const REQ_CREATE_NET_LOG: Req<void, APIServiceNetworkLogItem>;
|
40
42
|
export declare const REQ_HTTP_LOG: Req<void, APIServiceNetworkLogItem[]>;
|
41
43
|
export declare const REQ_HTTP_REQUESTS_COUNT: Req<void, number>;
|
42
|
-
export declare const REQ_HTTP_SERVER: Req<void,
|
44
|
+
export declare const REQ_HTTP_SERVER: Req<void, {
|
45
|
+
express: Application;
|
46
|
+
http: http.Server;
|
47
|
+
}>;
|
43
48
|
export declare function Initializer(services: IBaseService[]): Promise<void>;
|
44
49
|
export declare class APIService extends BaseService {
|
45
50
|
private static nextLogID;
|
@@ -49,6 +54,7 @@ export declare class APIService extends BaseService {
|
|
49
54
|
private monitorIndexFile?;
|
50
55
|
private started;
|
51
56
|
private requestsCount;
|
57
|
+
private server;
|
52
58
|
netLog: APIServiceNetworkLogItem[];
|
53
59
|
constructor(options?: APIServiceOptions | null);
|
54
60
|
init(): Promise<void>;
|
@@ -42,6 +42,7 @@ const express_fileupload_1 = __importDefault(require("express-fileupload"));
|
|
42
42
|
const os_1 = __importDefault(require("os"));
|
43
43
|
const Liveness_1 = require("./routes/Liveness");
|
44
44
|
const Readiness_1 = require("./routes/Readiness");
|
45
|
+
const http_1 = __importDefault(require("http"));
|
45
46
|
function getDefaultOptions() {
|
46
47
|
return {
|
47
48
|
port: 8091,
|
@@ -81,12 +82,13 @@ async function Initializer(services) {
|
|
81
82
|
exports.Initializer = Initializer;
|
82
83
|
class APIService extends BaseService_1.BaseService {
|
83
84
|
static nextLogID = 0;
|
84
|
-
version = "1.
|
85
|
+
version = "1.9.6";
|
85
86
|
options;
|
86
87
|
monitor;
|
87
88
|
monitorIndexFile;
|
88
89
|
started = new Date();
|
89
90
|
requestsCount = 0;
|
91
|
+
server = http_1.default;
|
90
92
|
netLog = [];
|
91
93
|
constructor(options) {
|
92
94
|
super('HTTP Service');
|
@@ -126,7 +128,8 @@ class APIService extends BaseService_1.BaseService {
|
|
126
128
|
return log;
|
127
129
|
};
|
128
130
|
const app = (0, express_1.default)();
|
129
|
-
|
131
|
+
const server = http_1.default.createServer(app);
|
132
|
+
exports.REQ_HTTP_SERVER.listener = async (ignore) => { return { express: app, http: server }; };
|
130
133
|
if (this.options.isProductionEnvironment)
|
131
134
|
app.set("env", 'production');
|
132
135
|
app.use(express_1.default.json({ limit: '10mb' }));
|
@@ -309,7 +312,7 @@ class APIService extends BaseService_1.BaseService {
|
|
309
312
|
httpStatus: 404
|
310
313
|
}, tme, req.path);
|
311
314
|
});
|
312
|
-
|
315
|
+
server.listen(this.options.port, () => {
|
313
316
|
(0, LogService_1.logCrit)('${APIService.js}', 'API Service started at: ' + this.options.port + ", with base endpoint:" + this.options.baseEndPoint + ", ver.: " + this.version);
|
314
317
|
});
|
315
318
|
}
|