minimonolith 0.25.19 → 0.25.21

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.19",
4
+ "version": "0.25.21",
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,17 @@ 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
+ [serviceRouteCode]: SERVICE_ERROR });
39
+
40
+ res.status(500).json({
41
+ [serviceRouteCode]: SERVICE_ERROR.toString() });
42
+ return;
32
43
  }
33
44
 
34
45
  let outBody = undefined;
@@ -41,9 +52,12 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
41
52
  const serviceRouteCode =
42
53
  await SERVICES.service.getRouteCode.handler({
43
54
  moduleName, serviceName });
55
+
44
56
  await SERVICES.api.postError.handler({
45
57
  [serviceRouteCode]: SERVICE_ERROR });
46
- res.status(500).json(SERVICE_ERROR);
58
+
59
+ res.status(500).json({
60
+ [serviceRouteCode]: SERVICE_ERROR.toString() });
47
61
  return;
48
62
  }
49
63
 
@@ -52,7 +66,7 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
52
66
 
53
67
  let parsedOutBody = outBody;
54
68
 
55
- {
69
+ try {
56
70
  const validationOut = await SERVICES.validation
57
71
  .getParsedAsync.handler({ ROUTE_CODE: ROUTE_CODE+'_OUT',
58
72
  VALIDATOR: service.out, input: outBody });
@@ -65,6 +79,17 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
65
79
  }
66
80
 
67
81
  if (validationOut) parsedOutBody = validationOut.parsedBody;
82
+ } catch (SERVICE_ERROR) {
83
+ const serviceRouteCode =
84
+ await SERVICES.service.getRouteCode.handler({
85
+ moduleName, serviceName });
86
+
87
+ await SERVICES.api.postError.handler({
88
+ [serviceRouteCode]: SERVICE_ERROR });
89
+
90
+ res.status(500).json({
91
+ [serviceRouteCode]: SERVICE_ERROR.toString() });
92
+ return;
68
93
  }
69
94
 
70
95
  const serviceResponseCode =