badmfck-api-server 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -193,6 +193,7 @@ class APIService extends BaseService_1.BaseService {
193
193
  if (!i.ignoreHttpLogging) {
194
194
  log = await exports.REQ_CREATE_NET_LOG.request();
195
195
  log.request = {
196
+ url: req.url,
196
197
  method: req.method,
197
198
  data: this.checkDataLength(req.body),
198
199
  params: this.checkDataLength(req.params)
@@ -363,12 +364,12 @@ class APIService extends BaseService_1.BaseService {
363
364
  if (data.rawResponse) {
364
365
  res.send(data.data);
365
366
  if (log)
366
- log.response = data.data;
367
+ log.response = this.checkDataLength(data);
367
368
  }
368
369
  else {
369
370
  res.send(data);
370
371
  if (log)
371
- log.response = data;
372
+ log.response = this.checkDataLength(data);
372
373
  if (data.error && this.monitor)
373
374
  this.monitor.registrateAPIError(data.endpoint);
374
375
  }
@@ -387,8 +388,6 @@ class APIService extends BaseService_1.BaseService {
387
388
  this.options.onNetworkLog(log);
388
389
  }
389
390
  checkDataLength(data, result, lvl) {
390
- if (!result)
391
- result = {};
392
391
  if (!lvl)
393
392
  lvl = 0;
394
393
  if (typeof data !== "object") {
@@ -397,6 +396,8 @@ class APIService extends BaseService_1.BaseService {
397
396
  return data;
398
397
  }
399
398
  if (typeof data === "object") {
399
+ if (!result)
400
+ result = {};
400
401
  let arrcnt = 100;
401
402
  for (let i in data) {
402
403
  result[i] = this.checkDataLength(data[i], result[i], lvl + 1);
@@ -407,7 +408,7 @@ class APIService extends BaseService_1.BaseService {
407
408
  }
408
409
  }
409
410
  }
410
- return result;
411
+ return result ?? null;
411
412
  }
412
413
  }
413
414
  exports.APIService = APIService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",