@karmaniverous/smoz 0.2.11 → 0.2.12
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/dist/cjs/index.js +24 -0
- package/dist/mjs/index.js +24 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -487,6 +487,30 @@ const makeErrorExpose = (logger) => tagStep({
|
|
|
487
487
|
/invalid (event|response)/i.test(msg))) {
|
|
488
488
|
maybe.statusCode = 400;
|
|
489
489
|
}
|
|
490
|
+
// JSON-encode the error message so middy's httpErrorHandler emits
|
|
491
|
+
// application/json instead of text/plain. Guard against double-encoding
|
|
492
|
+
// since this step is registered in both the after and onError arrays.
|
|
493
|
+
try {
|
|
494
|
+
const parsed = JSON.parse(msg);
|
|
495
|
+
if (typeof parsed === 'object' &&
|
|
496
|
+
parsed !== null &&
|
|
497
|
+
'statusCode' in parsed &&
|
|
498
|
+
'message' in parsed)
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
catch {
|
|
502
|
+
// not JSON — proceed with encoding
|
|
503
|
+
}
|
|
504
|
+
const statusCode = typeof maybe.statusCode === 'number'
|
|
505
|
+
? maybe.statusCode
|
|
506
|
+
: 500;
|
|
507
|
+
// Ensure statusCode is set so middy's httpErrorHandler doesn't
|
|
508
|
+
// discard the message with its fallback replacement.
|
|
509
|
+
if (typeof maybe.statusCode !== 'number') {
|
|
510
|
+
maybe.statusCode = statusCode;
|
|
511
|
+
}
|
|
512
|
+
const message = msg || 'Internal Server Error';
|
|
513
|
+
maybe.message = JSON.stringify({ statusCode, message });
|
|
490
514
|
},
|
|
491
515
|
}, 'error-expose');
|
|
492
516
|
const makeErrorHandler = (opts) => tagStep(asApiMiddleware(httpErrorHandler({
|
package/dist/mjs/index.js
CHANGED
|
@@ -485,6 +485,30 @@ const makeErrorExpose = (logger) => tagStep({
|
|
|
485
485
|
/invalid (event|response)/i.test(msg))) {
|
|
486
486
|
maybe.statusCode = 400;
|
|
487
487
|
}
|
|
488
|
+
// JSON-encode the error message so middy's httpErrorHandler emits
|
|
489
|
+
// application/json instead of text/plain. Guard against double-encoding
|
|
490
|
+
// since this step is registered in both the after and onError arrays.
|
|
491
|
+
try {
|
|
492
|
+
const parsed = JSON.parse(msg);
|
|
493
|
+
if (typeof parsed === 'object' &&
|
|
494
|
+
parsed !== null &&
|
|
495
|
+
'statusCode' in parsed &&
|
|
496
|
+
'message' in parsed)
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
// not JSON — proceed with encoding
|
|
501
|
+
}
|
|
502
|
+
const statusCode = typeof maybe.statusCode === 'number'
|
|
503
|
+
? maybe.statusCode
|
|
504
|
+
: 500;
|
|
505
|
+
// Ensure statusCode is set so middy's httpErrorHandler doesn't
|
|
506
|
+
// discard the message with its fallback replacement.
|
|
507
|
+
if (typeof maybe.statusCode !== 'number') {
|
|
508
|
+
maybe.statusCode = statusCode;
|
|
509
|
+
}
|
|
510
|
+
const message = msg || 'Internal Server Error';
|
|
511
|
+
maybe.message = JSON.stringify({ statusCode, message });
|
|
488
512
|
},
|
|
489
513
|
}, 'error-expose');
|
|
490
514
|
const makeErrorHandler = (opts) => tagStep(asApiMiddleware(httpErrorHandler({
|
package/package.json
CHANGED
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
"templates:lint": "eslint --fix -c templates/default/eslint.config.ts \"templates/default/**/*.{ts,tsx,js,jsx}\" \"templates/default/eslint.config.ts\""
|
|
185
185
|
},
|
|
186
186
|
"type": "module",
|
|
187
|
-
"version": "0.2.
|
|
187
|
+
"version": "0.2.12",
|
|
188
188
|
"volta": {
|
|
189
189
|
"node": "22.19.0"
|
|
190
190
|
}
|