minimonolith 0.25.20 → 0.25.22

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,7 +1,7 @@
1
1
  {
2
2
  "name": "minimonolith",
3
3
  "type": "module",
4
- "version": "0.25.20",
4
+ "version": "0.25.22",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -16,7 +16,7 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
16
16
 
17
17
  let parsedInBody = inBody;
18
18
 
19
- {
19
+ try {
20
20
  const validationIn = await SERVICES.validation
21
21
  .getParsedAsync.handler({ ROUTE_CODE: ROUTE_CODE+'_IN',
22
22
  VALIDATOR: service.in, input: inBody });
@@ -29,6 +29,18 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
29
29
  }
30
30
 
31
31
  if (validationIn) parsedInBody = validationIn.parsedBody;
32
+ } catch (SERVICE_ERROR) {
33
+ const serviceRouteCode =
34
+ await SERVICES.service.getRouteCode.handler({
35
+ moduleName, serviceName });
36
+
37
+ await SERVICES.api.postError.handler({
38
+ STAGE: 'VALIDATION_IN',
39
+ [serviceRouteCode]: SERVICE_ERROR });
40
+
41
+ res.status(500).json({
42
+ [serviceRouteCode]: SERVICE_ERROR.toString() });
43
+ return;
32
44
  }
33
45
 
34
46
  let outBody = undefined;
@@ -43,6 +55,7 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
43
55
  moduleName, serviceName });
44
56
 
45
57
  await SERVICES.api.postError.handler({
58
+ STAGE: 'HANDLER',
46
59
  [serviceRouteCode]: SERVICE_ERROR });
47
60
 
48
61
  res.status(500).json({
@@ -55,7 +68,7 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
55
68
 
56
69
  let parsedOutBody = outBody;
57
70
 
58
- {
71
+ try {
59
72
  const validationOut = await SERVICES.validation
60
73
  .getParsedAsync.handler({ ROUTE_CODE: ROUTE_CODE+'_OUT',
61
74
  VALIDATOR: service.out, input: outBody });
@@ -68,6 +81,18 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
68
81
  }
69
82
 
70
83
  if (validationOut) parsedOutBody = validationOut.parsedBody;
84
+ } catch (SERVICE_ERROR) {
85
+ const serviceRouteCode =
86
+ await SERVICES.service.getRouteCode.handler({
87
+ moduleName, serviceName });
88
+
89
+ await SERVICES.api.postError.handler({
90
+ STAGE: 'VALIDATION_OUT',
91
+ [serviceRouteCode]: SERVICE_ERROR });
92
+
93
+ res.status(500).json({
94
+ [serviceRouteCode]: SERVICE_ERROR.toString() });
95
+ return;
71
96
  }
72
97
 
73
98
  const serviceResponseCode =
@@ -29,7 +29,7 @@ export default async ({ body, SERVICES }) => {
29
29
  if (VALIDATION_ERROR) {
30
30
  const MESSAGE = { ROUTE_CODE,
31
31
  VALIDATION_ERROR: JSON.stringify(VALIDATION_ERROR) };
32
- await SERVICES.api.postInfo.handler(MESSAGE);
32
+ //await SERVICES.api.postInfo.handler(MESSAGE);
33
33
  return { error: MESSAGE };
34
34
  }
35
35