badmfck-api-server 4.0.85 → 4.0.87

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.
@@ -127,6 +127,7 @@ export declare class DBService extends BaseService {
127
127
  adapter: IDBAdapter | null;
128
128
  constructor(options: IDBSericeOptions);
129
129
  init(): Promise<void>;
130
+ escape(id: string, value: string): string;
130
131
  getAdapter(dbid?: string | null): IDBAdapter | IDBError;
131
132
  reportQuery(result: IDBResult, req: IDBQuery): Promise<void>;
132
133
  finishService(): Promise<void>;
@@ -240,6 +240,12 @@ class DBService extends BaseService_1.BaseService {
240
240
  return errorResult;
241
241
  };
242
242
  }
243
+ escape(id, value) {
244
+ const adapter = this.getAdapter(id);
245
+ if (!adapter || "errno" in adapter)
246
+ return value;
247
+ return adapter.escape(value);
248
+ }
243
249
  getAdapter(dbid) {
244
250
  if (!dbid && DBService.allInstances.length === 1 && DBService.allInstances[0].adapter)
245
251
  return DBService.allInstances[0].adapter;
@@ -9,4 +9,5 @@ export interface IDBAdapter {
9
9
  query(request: IDBQuery): Promise<IDBResult>;
10
10
  bulk(request: IDBBulkQuery): Promise<IDBResult[]>;
11
11
  poolStatus(): IPoolStatus;
12
+ escape(value: string): string;
12
13
  }
@@ -31,6 +31,7 @@ export declare class MysqlAdapter implements IDBAdapter {
31
31
  poolConnections: number;
32
32
  acquiredPoolConnections: number;
33
33
  constructor(options: DBAdapterOptions);
34
+ escape(value: string): string;
34
35
  init(): Promise<void>;
35
36
  poolStatus(): {
36
37
  lastSuccessQueryTime: string;
@@ -39,6 +39,9 @@ class MysqlAdapter {
39
39
  if (this.options.password.startsWith("_"))
40
40
  this.options.password = decrypt(this.options.password.substring(1)) ?? this.options.password;
41
41
  }
42
+ escape(value) {
43
+ return promise_1.default.escape(value);
44
+ }
42
45
  async init() {
43
46
  if (this.options.transactionFailReportDir) {
44
47
  try {
@@ -18,6 +18,7 @@ export declare class PostgresAdapter implements IDBAdapter {
18
18
  poolConnections: number;
19
19
  acquiredPoolConnections: number;
20
20
  constructor(options: DBAdapterOptions);
21
+ escape(value: string): string;
21
22
  tBegin?(): Promise<IDBResult>;
22
23
  tCommit?(trxid: number): Promise<IDBResult>;
23
24
  tRollback?(trxid: number): Promise<IDBResult>;
@@ -21,6 +21,9 @@ class PostgresAdapter {
21
21
  constructor(options) {
22
22
  this.options = options;
23
23
  }
24
+ escape(value) {
25
+ return value;
26
+ }
24
27
  tBegin() {
25
28
  throw new Error('Method not implemented.');
26
29
  }
@@ -103,7 +103,7 @@ class MicroserviceHost extends BaseService_1.BaseService {
103
103
  const request = JSON.parse(decrypted.toString("utf8"));
104
104
  const reqCall = this.options.requests.find(r => r.name === request?.requestName);
105
105
  if (!reqCall)
106
- return { ...DefaultErrors_1.default.BAD_REQUEST, details: "method not found" };
106
+ return { ...DefaultErrors_1.default.NOT_FOUND, details: "request not registered: " + request?.requestName };
107
107
  const job = {
108
108
  status: "processing",
109
109
  expires: Date.now() + 1000 * 60 * 5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "4.0.85",
3
+ "version": "4.0.87",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",