@mondart/nestjs-common-module 1.1.54 → 1.1.55

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.
@@ -2,4 +2,5 @@ export * from './get-env.helper';
2
2
  export * from './multi-inheritance.helper';
3
3
  export * from './message-formatter.helper';
4
4
  export * from './convert-string-case.helper';
5
- export * from './kafka-catch-error.helper';
5
+ export * from './rxjs-catch-error.helper';
6
+ export * from './rxjs-timeout-custom-callback.helper';
@@ -18,4 +18,5 @@ __exportStar(require("./get-env.helper"), exports);
18
18
  __exportStar(require("./multi-inheritance.helper"), exports);
19
19
  __exportStar(require("./message-formatter.helper"), exports);
20
20
  __exportStar(require("./convert-string-case.helper"), exports);
21
- __exportStar(require("./kafka-catch-error.helper"), exports);
21
+ __exportStar(require("./rxjs-catch-error.helper"), exports);
22
+ __exportStar(require("./rxjs-timeout-custom-callback.helper"), exports);
@@ -0,0 +1 @@
1
+ export declare function RxjsCatchErrorHelper(): import("rxjs").OperatorFunction<unknown, unknown>;
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KafkaCatchErrorHelper = KafkaCatchErrorHelper;
3
+ exports.RxjsCatchErrorHelper = RxjsCatchErrorHelper;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const exceptions = require("@nestjs/common/exceptions");
6
- function KafkaCatchErrorHelper() {
7
- return (err) => {
6
+ const rxjs_1 = require("rxjs");
7
+ function RxjsCatchErrorHelper() {
8
+ return (0, rxjs_1.catchError)((err) => {
8
9
  if (exceptions[err?.name])
9
10
  throw new exceptions[err.name](err);
10
11
  else if (Object.keys(strapiApplicationErrors).includes(err?.name))
11
12
  throw new strapiApplicationErrors[err?.name](err?.response);
12
13
  else
13
14
  throw new common_1.InternalServerErrorException(err);
14
- };
15
+ });
15
16
  }
16
17
  const strapiApplicationErrors = {
17
18
  ApplicationError: exceptions.InternalServerErrorException,
@@ -0,0 +1,2 @@
1
+ import { ObservableInput, ObservedValueOf, OperatorFunction, TimeoutConfig } from 'rxjs';
2
+ export declare function RxjsCustomTimeoutHelper<T, O extends ObservableInput<unknown>, M = unknown>(timeoutSeconds: number, serviceName: string, methodName: string, config?: TimeoutConfig<T, O, M>): OperatorFunction<T, T | ObservedValueOf<O>>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RxjsCustomTimeoutHelper = RxjsCustomTimeoutHelper;
4
+ const rxjs_1 = require("rxjs");
5
+ const common_1 = require("@nestjs/common");
6
+ const convert_string_case_helper_1 = require("./convert-string-case.helper");
7
+ function RxjsCustomTimeoutHelper(timeoutSeconds, serviceName, methodName, config) {
8
+ return (0, rxjs_1.timeout)({
9
+ each: timeoutSeconds * 1000,
10
+ with: () => (0, rxjs_1.throwError)(() => new common_1.GatewayTimeoutException(`${convert_string_case_helper_1.ConvertStringCaseHelper.camelToKebab(serviceName)}-` +
11
+ `${convert_string_case_helper_1.ConvertStringCaseHelper.camelToKebab(methodName)}: ` +
12
+ `Timeout has occurred`)),
13
+ ...config,
14
+ });
15
+ }