badmfck-api-server 3.8.5 → 3.8.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.
@@ -46,9 +46,6 @@ const MysqlAdapter_1 = require("./db/MysqlAdapter");
46
46
  const DocumentService_1 = require("./DocumentService");
47
47
  const Documentation_1 = require("./documentation/Documentation");
48
48
  let nextLogID = 0;
49
- function bindRequestToOptions(opts, req) {
50
- return req;
51
- }
52
49
  function defaultOptions() {
53
50
  return {
54
51
  port: 8080,
@@ -96,7 +93,7 @@ async function Initializer(services) {
96
93
  }
97
94
  exports.Initializer = Initializer;
98
95
  class APIService extends BaseService_1.BaseService {
99
- version = "3.8.5";
96
+ version = "3.8.6";
100
97
  options;
101
98
  monitor = null;
102
99
  started = new Date();
@@ -277,14 +274,12 @@ class APIService extends BaseService_1.BaseService {
277
274
  if (!ignoreInterceptor) {
278
275
  let interceptorResult;
279
276
  if (this.options.interceptor) {
280
- const httpRequestBound = bindRequestToOptions(this.options, httpRequest);
281
277
  interceptorResult = await this.options.interceptor.intercept(httpRequest);
282
278
  if (DefaultErrors_1.ErrorUtils.isError(interceptorResult) && !allowInterceptorError) {
283
279
  this.sendResponse(req.get("Referer") ?? "", res, interceptorResult, tme, ep, httpRequest);
284
280
  return;
285
281
  }
286
- httpRequestBound.interceptorResult = interceptorResult;
287
- httpRequest = httpRequestBound;
282
+ httpRequest.interceptorResult = interceptorResult;
288
283
  }
289
284
  }
290
285
  const precheck = await i.__precheck(httpRequest);
@@ -413,6 +408,10 @@ class APIService extends BaseService_1.BaseService {
413
408
  httpStatus: 500
414
409
  }, requestTime, data.endpoint, req);
415
410
  }
411
+ else {
412
+ if (req)
413
+ this.addNetlog(data, req, requestTime, 0);
414
+ }
416
415
  });
417
416
  return;
418
417
  }
@@ -445,6 +444,8 @@ class APIService extends BaseService_1.BaseService {
445
444
  console.error(e);
446
445
  }
447
446
  }
447
+ if (req)
448
+ this.addNetlog(data, req, requestTime, 0);
448
449
  }
449
450
  checkDataLength(data, result, lvl) {
450
451
  if (!lvl)
@@ -9,6 +9,7 @@ export interface IDBQueryField {
9
9
  ignoreInUpdate?: boolean;
10
10
  useInReplace?: boolean;
11
11
  __parsedValue?: string | number | boolean | null | undefined;
12
+ fields?: Record<string, number | boolean | string | null>;
12
13
  }
13
14
  export interface IDBQueryFields {
14
15
  [key: string]: string | number | boolean | IDBQueryField | null;
@@ -606,6 +606,14 @@ class MysqlAdapter {
606
606
  }
607
607
  if (typeof value === "boolean")
608
608
  value = value ? 1 : 0;
609
+ if (field.fields && typeof field.fields === "object" && value && typeof value === "string" && value.indexOf("@") !== -1) {
610
+ for (let key in field.fields) {
611
+ if (!field.fields[key])
612
+ continue;
613
+ const val = promise_1.default.escape(field.fields[key]);
614
+ value = this.safeReplace(value, key, val);
615
+ }
616
+ }
609
617
  field.__parsedValue = value;
610
618
  if (field.__parsedValue === null || field.__parsedValue === undefined) {
611
619
  field.__parsedValue = "NULL";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "3.8.5",
3
+ "version": "3.8.6",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",