@lucaapp/service-utils 1.56.4 → 1.56.5

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.
@@ -121,8 +121,7 @@ const isTypedError = (error) => {
121
121
  const validateAndSendResponse = async (expressResponse, response, validResponses, debug) => {
122
122
  try {
123
123
  (0, assert_1.default)(typeof response.status === 'number');
124
- // get schema respective to status code
125
- const responseSchema = validResponses.find(responseSchema => responseSchema.status === response.status);
124
+ const responseSchema = validResponses.find(r => r.status === response.status);
126
125
  const schema = responseSchema?.schema;
127
126
  (0, assert_1.default)(schema);
128
127
  if (response.headers) {
@@ -130,10 +129,16 @@ const validateAndSendResponse = async (expressResponse, response, validResponses
130
129
  expressResponse.set(header, value);
131
130
  });
132
131
  }
133
- // validate response schema
134
- const validatedResponseBody = await schema.parseAsync(response.body);
132
+ const validatedResponseBody = await schema
133
+ .parseAsync(response.body)
134
+ .catch(error => {
135
+ if (debug || process.env.NODE_ENV !== 'production') {
136
+ throw error;
137
+ }
138
+ console.error('Response schema validation failed:', error);
139
+ return response.body; // Return original body in production
140
+ });
135
141
  if (validatedResponseBody === undefined) {
136
- // No Content Response
137
142
  expressResponse.status(response.status).end();
138
143
  return;
139
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucaapp/service-utils",
3
- "version": "1.56.4",
3
+ "version": "1.56.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [