badmfck-api-server 4.1.11 → 4.1.12

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.
@@ -98,7 +98,7 @@ async function Initializer(services) {
98
98
  }
99
99
  exports.Initializer = Initializer;
100
100
  class APIService extends BaseService_1.BaseService {
101
- version = "4.1.11";
101
+ version = "4.1.12";
102
102
  options;
103
103
  monitor = null;
104
104
  started = new Date();
@@ -552,8 +552,10 @@ class MysqlAdapter {
552
552
  }
553
553
  if (trx && !error.isDuplicateError)
554
554
  this.storeTransactionAsProblem(trx, "error:" + error.errno);
555
- if (request.throwable)
556
- throw { ...DefaultErrors_1.default.DB_ERROR, details: error.message, stack: error };
555
+ if (request.throwable) {
556
+ const base = error.isDuplicateError ? DefaultErrors_1.default.DB_DUPLICATE_ERROR : DefaultErrors_1.default.DB_ERROR;
557
+ throw { ...base, details: error.message, stack: error };
558
+ }
557
559
  return {
558
560
  data: null,
559
561
  error: error,
@@ -12,6 +12,7 @@ declare class DefaultErrors {
12
12
  static TIMEOUT: IError;
13
13
  static METHOD_NOT_ALLOWED: IError;
14
14
  static DB_ERROR: IError;
15
+ static DB_DUPLICATE_ERROR: IError;
15
16
  static FORBIDDEN: IError;
16
17
  static NOT_FOUND: IError;
17
18
  static INTERNAL_SERVER_ERROR: IError;
@@ -15,6 +15,7 @@ class DefaultErrors {
15
15
  static TIMEOUT = { code: 9, message: "Timeout", httpStatus: 408 };
16
16
  static METHOD_NOT_ALLOWED = { code: 10, message: "Method not allowed", httpStatus: 405 };
17
17
  static DB_ERROR = { code: 11, message: "DB error", httpStatus: 500 };
18
+ static DB_DUPLICATE_ERROR = { code: 28, message: "DB duplicate entry", httpStatus: 409 };
18
19
  static FORBIDDEN = { code: 12, message: "Forbidden", httpStatus: 403 };
19
20
  static NOT_FOUND = { code: 13, message: "Not found", httpStatus: 404 };
20
21
  static INTERNAL_SERVER_ERROR = { code: 14, message: "Internal server error.", httpStatus: 500 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "4.1.11",
3
+ "version": "4.1.12",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",