@autofleet/sequelize-utils 5.0.0 → 5.0.2

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.
package/dist/index.js CHANGED
@@ -14,7 +14,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  /* eslint-disable import/prefer-default-export */
16
16
  const sequelize_1 = require("sequelize");
17
- const logger_1 = __importDefault(require("../../logger"));
17
+ const debug_1 = __importDefault(require("debug"));
18
+ const log = debug_1.default('sequelize-utils');
18
19
  exports.default = (sequelize) => {
19
20
  const transactionWithRetry = (funcToRun, retriesCount = 2) => __awaiter(void 0, void 0, void 0, function* () {
20
21
  try {
@@ -27,10 +28,10 @@ exports.default = (sequelize) => {
27
28
  catch (e) {
28
29
  if (e instanceof sequelize_1.DatabaseError) {
29
30
  if (retriesCount === 0) {
30
- logger_1.default.error('error inside transactionWithRetry - will stop retry', e);
31
+ log('error inside transactionWithRetry - will stop retry', e);
31
32
  throw e;
32
33
  }
33
- logger_1.default.error(`error inside transactionWithRetry - will retry times ${retriesCount - 1}`, e);
34
+ log(`error inside transactionWithRetry - will retry times ${retriesCount - 1}`, e);
34
35
  return transactionWithRetry(funcToRun, retriesCount - 1);
35
36
  }
36
37
  throw e;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@autofleet/sequelize-utils",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "start": "ts-node src/index.ts",
8
8
  "example": "ts-node src/example.ts",
@@ -16,18 +16,23 @@
16
16
  "author": "",
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
+ "debug": "^4.3.2",
20
+ "jest": "^27.0.6",
19
21
  "sequelize": "^5.22.3"
20
22
  },
21
23
  "devDependencies": {
22
24
  "@types/bluebird": "^3.5.36",
25
+ "@types/debug": "^4.1.6",
26
+ "@types/jest": "^26.0.24",
23
27
  "@types/validator": "^13.6.3",
24
28
  "@typescript-eslint/eslint-plugin": "^4.28.3",
25
29
  "@typescript-eslint/parser": "^4.28.3",
26
30
  "eslint": "^7.31.0",
27
31
  "eslint-config-airbnb-base": "^14.2.1",
28
32
  "eslint-plugin-import": "^2.23.4",
33
+ "pg": "^8.6.0",
34
+ "ts-jest": "^27.0.3",
29
35
  "ts-node": "^10.1.0",
30
- "tsc": "^2.0.3",
31
36
  "typescript": "^4.3.5"
32
37
  }
33
38
  }
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
2
  import { DatabaseError, Sequelize, Transaction } from 'sequelize';
3
- import logger from '../../logger';
3
+ import debug from 'debug';
4
+
5
+ const log = debug('sequelize-utils');
4
6
 
5
7
  export default (sequelize: Sequelize): {
6
8
  transactionWithRetry: any,
@@ -16,10 +18,10 @@ export default (sequelize: Sequelize): {
16
18
  } catch (e) {
17
19
  if (e instanceof DatabaseError) {
18
20
  if (retriesCount === 0) {
19
- logger.error('error inside transactionWithRetry - will stop retry', e);
21
+ log('error inside transactionWithRetry - will stop retry', e);
20
22
  throw e;
21
23
  }
22
- logger.error(`error inside transactionWithRetry - will retry times ${retriesCount - 1}`, e);
24
+ log(`error inside transactionWithRetry - will retry times ${retriesCount - 1}`, e);
23
25
  return transactionWithRetry(funcToRun, retriesCount - 1);
24
26
  }
25
27
  throw e;