badmfck-api-server 3.8.2 → 3.8.4
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.
@@ -22,17 +22,18 @@ export interface APIServiceNetworkLogItem {
|
|
22
22
|
};
|
23
23
|
error?: string | null;
|
24
24
|
}
|
25
|
-
export interface
|
25
|
+
export interface IInterceptor<T> {
|
26
|
+
intercept(req: HTTPRequestVO<any>): Promise<T | IError>;
|
27
|
+
}
|
28
|
+
export interface APIServiceOptions<TInterceptor = unknown> {
|
26
29
|
port: number;
|
27
30
|
baseEndPoint: string;
|
28
31
|
corsHostWhiteList: string[];
|
29
32
|
projectName: string;
|
30
33
|
endpoints: IBaseEndpoint[];
|
31
34
|
jsonLimit: string;
|
32
|
-
onNetworkLog?: ((log: APIServiceNetworkLogItem) => void) | null;
|
33
|
-
onError?: ((...rest: any[]) => void) | null;
|
34
35
|
isProductionEnvironment: boolean;
|
35
|
-
interceptor?:
|
36
|
+
interceptor?: IInterceptor<TInterceptor>;
|
36
37
|
postproducer?: (req: HTTPRequestVO | undefined | null, res: Response, data: TransferPacketVO<any>, requestTime: number, endpoint?: string, log?: APIServiceNetworkLogItem | null) => Promise<TransferPacketVO>;
|
37
38
|
preproducer?: (req: HTTPRequestVO | undefined | null) => any;
|
38
39
|
access: {
|
@@ -44,8 +45,11 @@ export interface APIServiceOptions {
|
|
44
45
|
fileTempDir: string;
|
45
46
|
fileLimit: number;
|
46
47
|
}
|
47
|
-
|
48
|
-
export declare const
|
48
|
+
type InferInterceptor<T> = T extends IInterceptor<infer U> ? U : unknown;
|
49
|
+
export declare const getDefaultOptions: <I extends IInterceptor<any> | undefined>(overrides?: (Omit<Partial<APIServiceOptions<InferInterceptor<NonNullable<I>>>>, "interceptor"> & {
|
50
|
+
interceptor?: I | undefined;
|
51
|
+
}) | undefined) => APIServiceOptions<InferInterceptor<NonNullable<I>>>;
|
52
|
+
export declare const REQ_DEPREACTED_CREATE_NET_LOG: Req<void, APIServiceNetworkLogItem>;
|
49
53
|
export declare const REQ_HTTP_LOG: Req<void, APIServiceNetworkLogItem[]>;
|
50
54
|
export declare const REQ_HTTP_REQUESTS_COUNT: Req<void, number>;
|
51
55
|
export declare const REQ_HTTP_SERVER: Req<void, {
|
@@ -64,8 +68,10 @@ export declare class APIService extends BaseService {
|
|
64
68
|
private started;
|
65
69
|
private requestsCount;
|
66
70
|
netLog: APIServiceNetworkLogItem[];
|
67
|
-
constructor(options
|
71
|
+
constructor(options: APIServiceOptions);
|
68
72
|
init(): Promise<void>;
|
69
|
-
|
73
|
+
addNetlog(data: TransferPacketVO, req: HTTPRequestVO, created: number, time: number): void;
|
74
|
+
sendResponse(ref: string, res: Response, data: TransferPacketVO<any>, requestTime: number, endpoint?: string, req?: HTTPRequestVO): Promise<void>;
|
70
75
|
checkDataLength(data: any, result?: any, lvl?: number): any;
|
71
76
|
}
|
77
|
+
export {};
|
@@ -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.REQ_DEPREACTED_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"));
|
@@ -35,9 +35,7 @@ const DefaultErrors_1 = __importStar(require("./structures/DefaultErrors"));
|
|
35
35
|
const badmfck_signal_1 = require("badmfck-signal");
|
36
36
|
const LogService_1 = require("./LogService");
|
37
37
|
const Monitor_1 = require("./monitor/Monitor");
|
38
|
-
const path_1 = __importDefault(require("path"));
|
39
38
|
const express_fileupload_1 = __importDefault(require("express-fileupload"));
|
40
|
-
const os_1 = __importDefault(require("os"));
|
41
39
|
const Liveness_1 = require("./routes/Liveness");
|
42
40
|
const Readiness_1 = require("./routes/Readiness");
|
43
41
|
const http_1 = __importDefault(require("http"));
|
@@ -47,33 +45,35 @@ const MonitorService_1 = require("./MonitorService");
|
|
47
45
|
const MysqlAdapter_1 = require("./db/MysqlAdapter");
|
48
46
|
const DocumentService_1 = require("./DocumentService");
|
49
47
|
const Documentation_1 = require("./documentation/Documentation");
|
50
|
-
|
48
|
+
let nextLogID = 0;
|
49
|
+
function bindRequestToOptions(opts, req) {
|
50
|
+
return req;
|
51
|
+
}
|
52
|
+
function defaultOptions() {
|
51
53
|
return {
|
52
|
-
port:
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
},
|
57
|
-
baseEndPoint: '/api/',
|
58
|
-
corsHostWhiteList: [
|
59
|
-
'http://localhost:3000',
|
60
|
-
],
|
54
|
+
port: 8080,
|
55
|
+
baseEndPoint: "/api/",
|
56
|
+
corsHostWhiteList: [],
|
57
|
+
projectName: "App",
|
61
58
|
endpoints: [],
|
62
59
|
jsonLimit: "10mb",
|
63
|
-
onNetworkLog: function (log) {
|
64
|
-
(0, LogService_1.logAPI)("${APIService.js}", log);
|
65
|
-
},
|
66
|
-
onError: function (err) {
|
67
|
-
(0, LogService_1.logError)("${APIService.js}", err);
|
68
|
-
},
|
69
|
-
projectName: "API Service",
|
70
60
|
isProductionEnvironment: false,
|
71
|
-
|
72
|
-
|
61
|
+
interceptor: undefined,
|
62
|
+
postproducer: undefined,
|
63
|
+
preproducer: undefined,
|
64
|
+
access: {},
|
65
|
+
monitor: undefined,
|
66
|
+
appVersion: undefined,
|
67
|
+
fileTempDir: "/tmp",
|
68
|
+
fileLimit: 10_000_000,
|
73
69
|
};
|
74
70
|
}
|
71
|
+
const getDefaultOptions = (overrides) => {
|
72
|
+
const base = defaultOptions();
|
73
|
+
return { ...base, ...overrides };
|
74
|
+
};
|
75
75
|
exports.getDefaultOptions = getDefaultOptions;
|
76
|
-
exports.
|
76
|
+
exports.REQ_DEPREACTED_CREATE_NET_LOG = new badmfck_signal_1.Req(undefined, "REQ_CREATE_NET_LOG");
|
77
77
|
exports.REQ_HTTP_LOG = new badmfck_signal_1.Req(undefined, "REQ_HTTP_LOG");
|
78
78
|
exports.REQ_HTTP_REQUESTS_COUNT = new badmfck_signal_1.Req(undefined, "REQ_HTTP_REQUESTS_COUNT");
|
79
79
|
exports.REQ_HTTP_SERVER = new badmfck_signal_1.Req(undefined, "REQ_HTTP_SERVER");
|
@@ -95,7 +95,7 @@ async function Initializer(services) {
|
|
95
95
|
exports.Initializer = Initializer;
|
96
96
|
class APIService extends BaseService_1.BaseService {
|
97
97
|
static nextLogID = 0;
|
98
|
-
version = "3.8.
|
98
|
+
version = "3.8.4";
|
99
99
|
options;
|
100
100
|
monitor = null;
|
101
101
|
started = new Date();
|
@@ -103,7 +103,7 @@ class APIService extends BaseService_1.BaseService {
|
|
103
103
|
netLog = [];
|
104
104
|
constructor(options) {
|
105
105
|
super('HTTP Service');
|
106
|
-
this.options = options
|
106
|
+
this.options = options;
|
107
107
|
if (!this.options.corsHostWhiteList)
|
108
108
|
this.options.corsHostWhiteList = [];
|
109
109
|
const self = "http://localhost:" + this.options.port;
|
@@ -121,21 +121,7 @@ class APIService extends BaseService_1.BaseService {
|
|
121
121
|
exports.REQ_HTTP_REQUESTS_COUNT.listener = async () => this.requestsCount;
|
122
122
|
}
|
123
123
|
async init() {
|
124
|
-
exports.REQ_HTTP_LOG.listener = async (
|
125
|
-
exports.REQ_CREATE_NET_LOG.listener = async (ignore) => {
|
126
|
-
const log = {
|
127
|
-
created: +new Date(),
|
128
|
-
time: 0,
|
129
|
-
request: {},
|
130
|
-
response: {},
|
131
|
-
error: null,
|
132
|
-
id: APIService.nextLogID++
|
133
|
-
};
|
134
|
-
this.netLog.push(log);
|
135
|
-
if (this.netLog.length > 1000)
|
136
|
-
this.netLog.shift();
|
137
|
-
return log;
|
138
|
-
};
|
124
|
+
exports.REQ_HTTP_LOG.listener = async (_) => this.netLog;
|
139
125
|
exports.REQ_INTERNAL_CALL.listener = async (req) => {
|
140
126
|
for (let i of this.options.endpoints) {
|
141
127
|
if (!i || !i.endpoints)
|
@@ -167,7 +153,17 @@ class APIService extends BaseService_1.BaseService {
|
|
167
153
|
error: DefaultErrors_1.default.FILE_TOO_LARGE,
|
168
154
|
data: null,
|
169
155
|
httpStatus: 413,
|
170
|
-
}, +new Date(), req.path
|
156
|
+
}, +new Date(), req.path, {
|
157
|
+
endpoint: req.path,
|
158
|
+
headers: req.headers,
|
159
|
+
method: req.method,
|
160
|
+
data: req.body,
|
161
|
+
params: req.params,
|
162
|
+
interceptorResult: null,
|
163
|
+
raw: req,
|
164
|
+
response: undefined,
|
165
|
+
files: undefined
|
166
|
+
});
|
171
167
|
},
|
172
168
|
limits: { fileSize: this.options.fileLimit },
|
173
169
|
useTempFiles: true,
|
@@ -181,12 +177,6 @@ class APIService extends BaseService_1.BaseService {
|
|
181
177
|
return;
|
182
178
|
}
|
183
179
|
const tme = +new Date();
|
184
|
-
const log = await exports.REQ_CREATE_NET_LOG.request();
|
185
|
-
log.request = {
|
186
|
-
method: req.method,
|
187
|
-
data: "",
|
188
|
-
params: req.params
|
189
|
-
};
|
190
180
|
let responseError = DefaultErrors_1.default.UNKNOWN_REQUEST;
|
191
181
|
if (typeof err === "object" && err.status === 400 && 'body' in err && err.type === 'entity.parse.failed') {
|
192
182
|
responseError = DefaultErrors_1.default.JSON_MALFORMED;
|
@@ -195,7 +185,17 @@ class APIService extends BaseService_1.BaseService {
|
|
195
185
|
error: responseError,
|
196
186
|
data: null,
|
197
187
|
httpStatus: 400
|
198
|
-
}, tme, "",
|
188
|
+
}, tme, "", {
|
189
|
+
endpoint: "",
|
190
|
+
headers: req.headers,
|
191
|
+
method: req.method,
|
192
|
+
data: req.body,
|
193
|
+
params: req.params,
|
194
|
+
interceptorResult: null,
|
195
|
+
raw: req,
|
196
|
+
response: undefined,
|
197
|
+
files: undefined
|
198
|
+
});
|
199
199
|
});
|
200
200
|
const corsOptions = {
|
201
201
|
origin: (origin, callback) => {
|
@@ -216,16 +216,6 @@ class APIService extends BaseService_1.BaseService {
|
|
216
216
|
app.all(ep, async (req, res) => {
|
217
217
|
this.requestsCount++;
|
218
218
|
const tme = +new Date();
|
219
|
-
let log = null;
|
220
|
-
if (!i.ignoreHttpLogging) {
|
221
|
-
log = await exports.REQ_CREATE_NET_LOG.request();
|
222
|
-
log.request = {
|
223
|
-
url: req.url,
|
224
|
-
method: req.method,
|
225
|
-
data: this.checkDataLength(req.body),
|
226
|
-
params: this.checkDataLength(req.params)
|
227
|
-
};
|
228
|
-
}
|
229
219
|
const execute = async () => {
|
230
220
|
const body = req.body;
|
231
221
|
if (req.query && typeof req.query === "object") {
|
@@ -233,7 +223,7 @@ class APIService extends BaseService_1.BaseService {
|
|
233
223
|
body[i] = req.query[i];
|
234
224
|
}
|
235
225
|
}
|
236
|
-
|
226
|
+
let httpRequest = {
|
237
227
|
raw: req,
|
238
228
|
response: res,
|
239
229
|
method: req.method,
|
@@ -259,10 +249,10 @@ class APIService extends BaseService_1.BaseService {
|
|
259
249
|
stack = [e];
|
260
250
|
}
|
261
251
|
if ((0, MysqlAdapter_1.isError)(e)) {
|
262
|
-
this.sendResponse(req.get("Referer") ?? "", res, { error: { ...DefaultErrors_1.default.DB_ERROR, details: e.message } }, tme, ep,
|
252
|
+
this.sendResponse(req.get("Referer") ?? "", res, { error: { ...DefaultErrors_1.default.DB_ERROR, details: e.message } }, tme, ep, httpRequest);
|
263
253
|
return;
|
264
254
|
}
|
265
|
-
this.sendResponse(req.get("Referer") ?? "", res, { error: { code: 10002, message: "Internal server error!", stack: stack, details: details }, data: null, httpStatus: 500 }, tme, ep,
|
255
|
+
this.sendResponse(req.get("Referer") ?? "", res, { error: { code: 10002, message: "Internal server error!", stack: stack, details: details }, data: null, httpStatus: 500 }, tme, ep, httpRequest);
|
266
256
|
return;
|
267
257
|
}
|
268
258
|
}
|
@@ -286,17 +276,19 @@ class APIService extends BaseService_1.BaseService {
|
|
286
276
|
if (!ignoreInterceptor) {
|
287
277
|
let interceptorResult;
|
288
278
|
if (this.options.interceptor) {
|
289
|
-
|
290
|
-
|
291
|
-
|
279
|
+
const httpRequestBound = bindRequestToOptions(this.options, httpRequest);
|
280
|
+
interceptorResult = await this.options.interceptor.intercept(httpRequest);
|
281
|
+
if (DefaultErrors_1.ErrorUtils.isError(interceptorResult) && !allowInterceptorError) {
|
282
|
+
this.sendResponse(req.get("Referer") ?? "", res, interceptorResult, tme, ep, httpRequest);
|
292
283
|
return;
|
293
284
|
}
|
294
|
-
|
285
|
+
httpRequestBound.interceptorResult = interceptorResult;
|
286
|
+
httpRequest = httpRequestBound;
|
295
287
|
}
|
296
288
|
}
|
297
289
|
const precheck = await i.__precheck(httpRequest);
|
298
290
|
if (precheck && precheck.error) {
|
299
|
-
this.sendResponse(req.get("Referer") ?? "", res, precheck, tme, ep,
|
291
|
+
this.sendResponse(req.get("Referer") ?? "", res, precheck, tme, ep, httpRequest);
|
300
292
|
return;
|
301
293
|
}
|
302
294
|
httpRequest.precheck = precheck;
|
@@ -332,10 +324,10 @@ class APIService extends BaseService_1.BaseService {
|
|
332
324
|
error: { ...DefaultErrors_1.default.DB_ERROR, details: e.message }
|
333
325
|
};
|
334
326
|
}
|
335
|
-
this.sendResponse(req.get("Referer") ?? "", res, data, tme, ep,
|
327
|
+
this.sendResponse(req.get("Referer") ?? "", res, data, tme, ep, httpRequest);
|
336
328
|
return;
|
337
329
|
}
|
338
|
-
this.sendResponse(req.get("Referer") ?? "", res, result, tme, ep,
|
330
|
+
this.sendResponse(req.get("Referer") ?? "", res, result, tme, ep, httpRequest);
|
339
331
|
};
|
340
332
|
execute();
|
341
333
|
});
|
@@ -347,23 +339,51 @@ class APIService extends BaseService_1.BaseService {
|
|
347
339
|
error: DefaultErrors_1.default.UNKNOWN_REQUEST,
|
348
340
|
data: null,
|
349
341
|
httpStatus: 404
|
350
|
-
}, tme, req.path
|
342
|
+
}, tme, req.path, {
|
343
|
+
endpoint: req.path,
|
344
|
+
headers: req.headers,
|
345
|
+
method: req.method,
|
346
|
+
data: req.body,
|
347
|
+
params: req.params,
|
348
|
+
interceptorResult: null,
|
349
|
+
raw: req,
|
350
|
+
response: undefined,
|
351
|
+
files: undefined
|
352
|
+
});
|
351
353
|
});
|
352
354
|
server.listen(this.options.port, () => {
|
353
355
|
(0, LogService_1.logAPI)('${APIService.js}', 'API Service started at: ' + this.options.port + ", with base endpoint:" + this.options.baseEndPoint + ", ver.: " + this.version);
|
354
356
|
});
|
355
357
|
}
|
356
|
-
|
358
|
+
addNetlog(data, req, created, time) {
|
359
|
+
const logItem = {
|
360
|
+
id: nextLogID++,
|
361
|
+
created: created,
|
362
|
+
time: time,
|
363
|
+
request: {
|
364
|
+
endpoint: req?.endpoint,
|
365
|
+
headers: req?.headers,
|
366
|
+
method: req?.method,
|
367
|
+
data: req?.data,
|
368
|
+
params: req?.params,
|
369
|
+
interceptorResult: req?.interceptorResult
|
370
|
+
},
|
371
|
+
response: data
|
372
|
+
};
|
373
|
+
this.netLog.push(logItem);
|
374
|
+
if (this.netLog.length > 100)
|
375
|
+
this.netLog.shift();
|
376
|
+
}
|
377
|
+
async sendResponse(ref, res, data, requestTime, endpoint, req) {
|
357
378
|
if (data.blockResponse) {
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
this.options.onNetworkLog(log);
|
379
|
+
(0, LogService_1.logAPI)("Response blocked");
|
380
|
+
if (req)
|
381
|
+
this.addNetlog(data, req, requestTime, 0);
|
362
382
|
return;
|
363
383
|
}
|
364
384
|
if (this.options.postproducer) {
|
365
385
|
try {
|
366
|
-
data = await this.options.postproducer(req, res, data, requestTime, endpoint
|
386
|
+
data = await this.options.postproducer(req, res, data, requestTime, endpoint);
|
367
387
|
}
|
368
388
|
catch (e) {
|
369
389
|
(0, LogService_1.logError)("Postproducer error", e);
|
@@ -376,37 +396,28 @@ class APIService extends BaseService_1.BaseService {
|
|
376
396
|
data.endpoint = endpoint ?? "no_endpoint";
|
377
397
|
if (this.options.appVersion)
|
378
398
|
data.version = this.options.appVersion;
|
379
|
-
if (log) {
|
380
|
-
log.time = data.responseTime;
|
381
|
-
log.referer = ref;
|
382
|
-
}
|
383
399
|
MonitorService_1.S_STAT_REGISTRATE_REQUEST.invoke(data);
|
384
400
|
if (res.destroyed || res.closed) {
|
385
|
-
|
386
|
-
log.error = "Connection already closed, can't send response for: " + data.endpoint;
|
387
|
-
if (this.options.onError)
|
388
|
-
this.options.onError("Connection already closed, can't send response: " + data.endpoint, data);
|
401
|
+
(0, LogService_1.logAPI)("Connection already closed, can't send response for: " + data.endpoint);
|
389
402
|
}
|
390
403
|
else {
|
391
404
|
try {
|
392
405
|
if (data.file) {
|
393
406
|
res.sendFile(data.file, err => {
|
394
407
|
if (err) {
|
395
|
-
|
396
|
-
log.error = "Can't send file: " + data.file;
|
408
|
+
(0, LogService_1.logError)("Can't send file: " + data.file);
|
397
409
|
this.sendResponse(ref, res, {
|
398
410
|
error: DefaultErrors_1.default.CANT_SEND_FILE,
|
399
411
|
data: null,
|
400
412
|
httpStatus: 500
|
401
|
-
}, requestTime, data.endpoint);
|
413
|
+
}, requestTime, data.endpoint, req);
|
402
414
|
}
|
403
415
|
});
|
404
416
|
return;
|
405
417
|
}
|
406
418
|
if (data.redirect) {
|
407
419
|
res.redirect(data.redirect);
|
408
|
-
|
409
|
-
log.response = { redirect: data.redirect };
|
420
|
+
(0, LogService_1.logAPI)("redirect: " + data.redirect);
|
410
421
|
}
|
411
422
|
else {
|
412
423
|
if (data.headers) {
|
@@ -419,34 +430,20 @@ class APIService extends BaseService_1.BaseService {
|
|
419
430
|
res.statusCode = data.httpStatus ?? 200;
|
420
431
|
if (data.rawResponse) {
|
421
432
|
res.send(data.data);
|
422
|
-
|
423
|
-
log.response = this.checkDataLength(data);
|
433
|
+
(0, LogService_1.logAPI)(this.checkDataLength(data));
|
424
434
|
}
|
425
435
|
else {
|
426
436
|
res.send(data);
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
if (log)
|
431
|
-
log.error = data.error.message;
|
432
|
-
}
|
437
|
+
(0, LogService_1.logAPI)(this.checkDataLength(data));
|
438
|
+
if (data.error)
|
439
|
+
(0, LogService_1.logError)(data.error.message);
|
433
440
|
}
|
434
441
|
}
|
435
442
|
}
|
436
443
|
catch (e) {
|
437
|
-
|
438
|
-
this.options.onError("Can't send response", e);
|
439
|
-
if (log)
|
440
|
-
log.error = "Can't send response";
|
444
|
+
console.error(e);
|
441
445
|
}
|
442
446
|
}
|
443
|
-
if (log && log.error && this.options.onError) {
|
444
|
-
this.options.onError(log.error);
|
445
|
-
}
|
446
|
-
else {
|
447
|
-
if (this.options.onNetworkLog && log)
|
448
|
-
this.options.onNetworkLog(log);
|
449
|
-
}
|
450
447
|
}
|
451
448
|
checkDataLength(data, result, lvl) {
|
452
449
|
if (!lvl)
|
@@ -42,9 +42,8 @@ class TimeframeService extends BaseService_1.BaseService {
|
|
42
42
|
super("TimeframeService");
|
43
43
|
}
|
44
44
|
async init() {
|
45
|
-
super.init();
|
46
45
|
exports.REQ_TIMEFRAME_TASK_ADD.listener = async (req) => {
|
47
|
-
(0, LogService_1.logInfo)("Add tack
|
46
|
+
(0, LogService_1.logInfo)("Add tack " + req.name);
|
48
47
|
this.tasks.push(req);
|
49
48
|
};
|
50
49
|
this.intervalId = setInterval(() => {
|
@@ -63,14 +62,14 @@ class TimeframeService extends BaseService_1.BaseService {
|
|
63
62
|
if (now >= task.start && (!task.executed || task.executed < task.start)) {
|
64
63
|
if (now - task.start <= this.GRACE_WINDOW_MS) {
|
65
64
|
try {
|
66
|
-
(0, LogService_1.logInfo)("
|
65
|
+
(0, LogService_1.logInfo)("Execute task ", task.name);
|
67
66
|
if (task.callback.length > 0 && task.params)
|
68
67
|
task.callback(task.params);
|
69
68
|
else
|
70
69
|
task.callback();
|
71
70
|
task.executed = Date.now();
|
72
71
|
task.retries = 0;
|
73
|
-
(0, LogService_1.logInfo)("
|
72
|
+
(0, LogService_1.logInfo)("Executed task ", task.name);
|
74
73
|
if (task.repeat) {
|
75
74
|
task.start += task.repeat;
|
76
75
|
}
|
@@ -18,7 +18,7 @@ export interface TransferPacketVO<T = any> {
|
|
18
18
|
blockResponse?: boolean;
|
19
19
|
project?: string;
|
20
20
|
}
|
21
|
-
export interface HTTPRequestVO<T = any> {
|
21
|
+
export interface HTTPRequestVO<T = any, TInterceport = any> {
|
22
22
|
raw: any;
|
23
23
|
response: any;
|
24
24
|
method: string;
|
@@ -26,11 +26,9 @@ export interface HTTPRequestVO<T = any> {
|
|
26
26
|
params: {
|
27
27
|
[key: string]: string;
|
28
28
|
};
|
29
|
-
headers:
|
30
|
-
[key: string]: string;
|
31
|
-
};
|
29
|
+
headers: Record<string, string>;
|
32
30
|
endpoint: string;
|
33
|
-
interceptorResult?:
|
31
|
+
interceptorResult?: any;
|
34
32
|
preproducerResult?: any;
|
35
33
|
precheck?: TransferPacketVO<any> | null;
|
36
34
|
files: FileArray | null | undefined;
|
package/dist/index.d.ts
CHANGED
@@ -10,4 +10,5 @@ import { UID } from "./apiServer/helper/UID";
|
|
10
10
|
import { ExternalService } from "./apiServer/external/ExternalService";
|
11
11
|
import { DBService } from "./apiServer/DBService";
|
12
12
|
import { YYYYMMDDHH } from "./apiServer/helper/YYYYMMDDHH";
|
13
|
-
|
13
|
+
import { TimeframeService } from "./apiServer/TimeframeService";
|
14
|
+
export { UID, YYYYMMDDHH, APIService, Initializer, LocalRequest, ValidationModel, MysqlService, TimeframeService, Validator, LogService, DataProvider, ErrorUtils, ExternalService, DBService, S_MONITOR_REGISTRATE_ACTION };
|
package/dist/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.S_MONITOR_REGISTRATE_ACTION = exports.DBService = exports.ExternalService = exports.ErrorUtils = exports.DataProvider = exports.LogService = exports.Validator = exports.MysqlService = exports.LocalRequest = exports.Initializer = exports.APIService = exports.YYYYMMDDHH = exports.UID = void 0;
|
3
|
+
exports.S_MONITOR_REGISTRATE_ACTION = exports.DBService = exports.ExternalService = exports.ErrorUtils = exports.DataProvider = exports.LogService = exports.Validator = exports.TimeframeService = exports.MysqlService = exports.LocalRequest = exports.Initializer = exports.APIService = exports.YYYYMMDDHH = exports.UID = void 0;
|
4
4
|
const APIService_1 = require("./apiServer/APIService");
|
5
5
|
Object.defineProperty(exports, "APIService", { enumerable: true, get: function () { return APIService_1.APIService; } });
|
6
6
|
Object.defineProperty(exports, "Initializer", { enumerable: true, get: function () { return APIService_1.Initializer; } });
|
@@ -26,3 +26,5 @@ const DBService_1 = require("./apiServer/DBService");
|
|
26
26
|
Object.defineProperty(exports, "DBService", { enumerable: true, get: function () { return DBService_1.DBService; } });
|
27
27
|
const YYYYMMDDHH_1 = require("./apiServer/helper/YYYYMMDDHH");
|
28
28
|
Object.defineProperty(exports, "YYYYMMDDHH", { enumerable: true, get: function () { return YYYYMMDDHH_1.YYYYMMDDHH; } });
|
29
|
+
const TimeframeService_1 = require("./apiServer/TimeframeService");
|
30
|
+
Object.defineProperty(exports, "TimeframeService", { enumerable: true, get: function () { return TimeframeService_1.TimeframeService; } });
|