@sdflc/backend-helpers 1.0.107 → 1.0.108

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/build/BaseCore.js CHANGED
@@ -145,7 +145,7 @@ class BaseCore {
145
145
  }
146
146
  }
147
147
  async runAction(opt) {
148
- const { args, validate, doAuth, roles, action, hasTransaction, doingWhat, onException, shouldLogArgs, requireSpace, } = opt || {};
148
+ const { args, validate, doAuth, roles, action, hasTransaction, doingWhat, onException, shouldLogArgs, requireSpace, skipCheckResult, } = opt || {};
149
149
  // If we process action with the same requestId as requestId passed to the constructor it means
150
150
  // we are processing the same request from FE and can skip some of the operations like transactions and etc
151
151
  const sameRequest = !!this.config.context.requestId && args?.requestId === this.config.context.requestId;
@@ -239,7 +239,9 @@ class BaseCore {
239
239
  let time = this.measureTool.stop();
240
240
  this.logger.debug(`Authorization and validation time for the ${doingWhat} took ${time.durationMs} ms`);
241
241
  const result = await action(args, { ...actionOpt, validatedItems, args });
242
- await this.checkResult({ hasTransaction, result, sameRequest, doingWhat });
242
+ if (skipCheckResult !== true) {
243
+ await this.checkResult({ hasTransaction, result, sameRequest, doingWhat });
244
+ }
243
245
  time = this.measureTool.stop(doingWhat);
244
246
  this.logger.debug(`The ${time.name} process time is ${time.durationMs} ms`);
245
247
  return result;
@@ -41,6 +41,10 @@ class BaseController {
41
41
  if (result instanceof api_helpers_1.OpResult) {
42
42
  res.status(result.getHttpStatus()).json(result.toJS());
43
43
  }
44
+ else if (result?.redirectUrl) {
45
+ res.redirect(result?.redirectUrl);
46
+ next();
47
+ }
44
48
  else if (result) {
45
49
  res.status(200).json(result);
46
50
  }
@@ -139,7 +139,7 @@ class BaseCore {
139
139
  }
140
140
  }
141
141
  async runAction(opt) {
142
- const { args, validate, doAuth, roles, action, hasTransaction, doingWhat, onException, shouldLogArgs, requireSpace, } = opt || {};
142
+ const { args, validate, doAuth, roles, action, hasTransaction, doingWhat, onException, shouldLogArgs, requireSpace, skipCheckResult, } = opt || {};
143
143
  // If we process action with the same requestId as requestId passed to the constructor it means
144
144
  // we are processing the same request from FE and can skip some of the operations like transactions and etc
145
145
  const sameRequest = !!this.config.context.requestId && args?.requestId === this.config.context.requestId;
@@ -233,7 +233,9 @@ class BaseCore {
233
233
  let time = this.measureTool.stop();
234
234
  this.logger.debug(`Authorization and validation time for the ${doingWhat} took ${time.durationMs} ms`);
235
235
  const result = await action(args, { ...actionOpt, validatedItems, args });
236
- await this.checkResult({ hasTransaction, result, sameRequest, doingWhat });
236
+ if (skipCheckResult !== true) {
237
+ await this.checkResult({ hasTransaction, result, sameRequest, doingWhat });
238
+ }
237
239
  time = this.measureTool.stop(doingWhat);
238
240
  this.logger.debug(`The ${time.name} process time is ${time.durationMs} ms`);
239
241
  return result;
@@ -35,6 +35,10 @@ class BaseController {
35
35
  if (result instanceof OpResult) {
36
36
  res.status(result.getHttpStatus()).json(result.toJS());
37
37
  }
38
+ else if (result?.redirectUrl) {
39
+ res.redirect(result?.redirectUrl);
40
+ next();
41
+ }
38
42
  else if (result) {
39
43
  res.status(200).json(result);
40
44
  }
@@ -12,4 +12,5 @@ export interface CoreActionInterface {
12
12
  onException?(params: any, opt?: BaseCoreActionsInterface): Promise<any | undefined | null>;
13
13
  shouldLogArgs?: boolean;
14
14
  requireSpace?: boolean;
15
+ skipCheckResult?: boolean;
15
16
  }
@@ -12,4 +12,5 @@ export interface CoreActionInterface {
12
12
  onException?(params: any, opt?: BaseCoreActionsInterface): Promise<any | undefined | null>;
13
13
  shouldLogArgs?: boolean;
14
14
  requireSpace?: boolean;
15
+ skipCheckResult?: boolean;
15
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdflc/backend-helpers",
3
- "version": "1.0.107",
3
+ "version": "1.0.108",
4
4
  "description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
5
5
  "type": "commonjs",
6
6
  "exports": {