ismx-nexo-node-app 0.3.67 → 0.3.68

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.
@@ -75,6 +75,16 @@ class BusinessErrors {
75
75
  this.except("0013");
76
76
  return body;
77
77
  }
78
+ getBodyParam(param, body) {
79
+ let path = param.split(".");
80
+ let value = body;
81
+ for (let key of path) {
82
+ value = value[key];
83
+ if (value === undefined || value === null)
84
+ this.except("0014", param);
85
+ }
86
+ return value;
87
+ }
78
88
  getHeaders(key, headers) {
79
89
  if (!headers[key])
80
90
  this.except("0015", key);
@@ -34,6 +34,7 @@ export default class BusinessErrors {
34
34
  [key: string]: string;
35
35
  }): string;
36
36
  getBody<T>(body?: T): T;
37
+ getBodyParam(param: string, body: any): any;
37
38
  getHeaders(key: string, headers: {
38
39
  [key: string]: string;
39
40
  }): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.3.67",
3
+ "version": "0.3.68",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -72,6 +72,16 @@ export default class BusinessErrors {
72
72
  return body!;
73
73
  }
74
74
 
75
+ getBodyParam(param: string, body: any): any {
76
+ let path = param.split(".");
77
+ let value = body;
78
+ for (let key of path) {
79
+ value = value[key];
80
+ if (value === undefined || value === null) this.except("0014", param);
81
+ }
82
+ return value;
83
+ }
84
+
75
85
  getHeaders(key: string, headers: {[key: string]: string}): string {
76
86
  if (!headers[key]) this.except("0015", key)
77
87
  return headers[key];
@@ -52,7 +52,7 @@ export default class RepositoryRest<Body=any,Res=any> extends Repository
52
52
  return call.then(async (res: Response) => {
53
53
  let headers: any = {}; res.headers.forEach((value, key) => headers[key] = value);
54
54
  let response: HttpResponse<E> = {
55
- httpCode: res.status, content: (await res.json()) as E, headers
55
+ httpCode: res.status, content: (await res.json()) as E, headers
56
56
  };
57
57
  this.options?.onResponse?.(response);
58
58
  return response;