anote-server-libs 0.5.2 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anote-server-libs",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Helpers for express-TS servers",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withTransaction = void 0;
3
+ exports.withTransaction = exports.withTransactionConfig = void 0;
4
4
  const utils_1 = require("./utils");
5
+ exports.withTransactionConfig = {
6
+ timeoutMillis: 15000
7
+ };
5
8
  function withTransaction(repo, logger, previousMethod, lock) {
6
9
  return function (req, res, next) {
7
10
  const endTerminator = res.end.bind(res);
@@ -12,7 +15,7 @@ function withTransaction(repo, logger, previousMethod, lock) {
12
15
  const connectTimeoutHandler = setTimeout(() => {
13
16
  logger.error('Error timed out getting a client, exiting...');
14
17
  process.exit(22);
15
- }, 15000);
18
+ }, exports.withTransactionConfig.timeoutMillis);
16
19
  Promise.all([
17
20
  repo.db ? repo.db.connect() : Promise.resolve(undefined),
18
21
  repo.dbMssql ? Promise.resolve(repo.dbMssql.transaction()) : Promise.resolve(undefined)
@@ -5,9 +5,14 @@ import {jsonStringify, utils} from './utils';
5
5
 
6
6
  export const enum SystemLock {
7
7
  CHECK_CROSSING = 1,
8
- FLUSH_CALLS = 2
8
+ FLUSH_CALLS = 2,
9
+ TX_CHECK = 3
9
10
  }
10
11
 
12
+ export const withTransactionConfig = {
13
+ timeoutMillis: 15000
14
+ };
15
+
11
16
  export function withTransaction(repo: BaseModelRepository, logger: Logger, previousMethod: (req: Request, res: Response, next: NextFunction) => void, lock?: SystemLock) {
12
17
  return function(req: Request, res: Response, next: NextFunction) {
13
18
  const endTerminator = res.end.bind(res);
@@ -19,7 +24,7 @@ export function withTransaction(repo: BaseModelRepository, logger: Logger, previ
19
24
  // Timed out getting a client, restart worker or process...
20
25
  logger.error('Error timed out getting a client, exiting...');
21
26
  process.exit(22);
22
- }, 15000);
27
+ }, withTransactionConfig.timeoutMillis);
23
28
  Promise.all([
24
29
  repo.db ? repo.db.connect() : Promise.resolve(undefined),
25
30
  repo.dbMssql ? Promise.resolve(repo.dbMssql.transaction()) : Promise.resolve(undefined)