badmfck-api-server 1.1.5 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,8 +30,8 @@ function getDefaultOptions() {
30
30
  };
31
31
  }
32
32
  exports.getDefaultOptions = getDefaultOptions;
33
- exports.REQ_CREATE_NET_LOG = new badmfck_signal_1.Req();
34
- exports.REQ_HTTP_LOG = new badmfck_signal_1.Req();
33
+ exports.REQ_CREATE_NET_LOG = new badmfck_signal_1.Req("REQ_CREATE_NET_LOG");
34
+ exports.REQ_HTTP_LOG = new badmfck_signal_1.Req("REQ_HTTP_LOG");
35
35
  async function Initializer(services) {
36
36
  for (let i of services) {
37
37
  await i.init();
@@ -133,11 +133,13 @@ class APIService extends BaseService_1.BaseService {
133
133
  result = await i.execute(httpRequest);
134
134
  }
135
135
  catch (e) {
136
+ if (this.options.onError)
137
+ this.options.onError(e);
136
138
  this.sendResponse(res, {
137
139
  httpStatus: 500,
138
140
  error: {
139
141
  code: 10002,
140
- message: "Internal server error"
142
+ message: "Internal server error",
141
143
  }
142
144
  }, tme, ep, log);
143
145
  return;
@@ -7,7 +7,7 @@ exports.MysqlService = exports.executeQuery = exports.REQ_MYSQL_QUERY = void 0;
7
7
  const mysql_1 = __importDefault(require("mysql"));
8
8
  const BaseService_1 = require("./BaseService");
9
9
  const badmfck_signal_1 = require("badmfck-signal");
10
- exports.REQ_MYSQL_QUERY = new badmfck_signal_1.Req();
10
+ exports.REQ_MYSQL_QUERY = new badmfck_signal_1.Req("REQ_MYSQL_QUERY");
11
11
  const executeQuery = async (query) => { return await exports.REQ_MYSQL_QUERY.request(query); };
12
12
  exports.executeQuery = executeQuery;
13
13
  class MysqlService extends BaseService_1.BaseService {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@types/mysql": "^2.15.21",
22
22
  "axios": "^1.4.0",
23
- "badmfck-signal": "^1.2.6",
23
+ "badmfck-signal": "^1.2.7",
24
24
  "cors": "^2.8.5",
25
25
  "express": "^4.18.2",
26
26
  "mysql": "^2.18.1"