badmfck-api-server 1.1.8 → 1.1.9

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.
@@ -36,7 +36,8 @@ export declare class MysqlService extends BaseService {
36
36
  reconnecting: boolean;
37
37
  pool: Pool | null;
38
38
  options: MysqlServiceOptions;
39
- retries: number;
39
+ serviceStarted: boolean;
40
+ queries: never[];
40
41
  constructor(options: MysqlServiceOptions);
41
42
  static executeQuery(query: MySqlQuery | MySqlQuery[]): Promise<MysqlResult[]>;
42
43
  init(): Promise<void>;
@@ -15,7 +15,8 @@ class MysqlService extends BaseService_1.BaseService {
15
15
  reconnecting = false;
16
16
  pool = null;
17
17
  options;
18
- retries = 5;
18
+ serviceStarted = false;
19
+ queries = [];
19
20
  constructor(options) {
20
21
  super("mysql");
21
22
  this.options = options;
@@ -23,12 +24,18 @@ class MysqlService extends BaseService_1.BaseService {
23
24
  }
24
25
  static async executeQuery(query) { return await exports.REQ_MYSQL_QUERY.request(query); }
25
26
  async init() {
27
+ this.serviceStarted = false;
26
28
  const ok = await this.createPool();
27
29
  if (!ok) {
28
30
  if (this.options.onLog)
29
31
  this.options.onLog(2, "Mysql server not connected, retrying in 3 sec");
30
32
  setTimeout(() => { this.init(); }, 3000);
31
33
  }
34
+ else {
35
+ this.serviceStarted = true;
36
+ if (this.options.onLog)
37
+ this.options.onLog(1, "Mysql Service started!");
38
+ }
32
39
  exports.REQ_MYSQL_QUERY.listener = async (data) => {
33
40
  if (!Array.isArray(data))
34
41
  data = [data];
@@ -96,6 +103,8 @@ class MysqlService extends BaseService_1.BaseService {
96
103
  return query;
97
104
  }
98
105
  static prepareQueryFieldValue(value, system) {
106
+ if (value === null)
107
+ return "NULL";
99
108
  if (!system && typeof value === "string") {
100
109
  value = value ? value.replaceAll('"', '\\"') : null;
101
110
  value = '"' + value + '"';
@@ -121,6 +130,10 @@ class MysqlService extends BaseService_1.BaseService {
121
130
  });
122
131
  return;
123
132
  }
133
+ this.pool.on("error", (evt) => {
134
+ if (this.options.onLog)
135
+ this.options.onLog(2, `${evt}`);
136
+ });
124
137
  this.pool.getConnection((err, conn) => {
125
138
  if (err) {
126
139
  if (this.options.onLog)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",