hono-utils 0.3.6 → 0.3.8
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/index.cjs +14 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
|
|
2
2
|
var __export = (target, all) => {
|
|
3
3
|
for (var name in all)
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -14216,7 +14216,7 @@ var onError = (parseError) => async (err, { json: json2, env, get }) => {
|
|
|
14216
14216
|
const status = "status" in err ? err.status : 500;
|
|
14217
14217
|
return json2(
|
|
14218
14218
|
{
|
|
14219
|
-
message: !parseError ? err.message : await parseError(err, env, get)
|
|
14219
|
+
message: !parseError ? err.message : await _asyncNullishCoalesce(await parseError(err, env, get), async () => ( defaultMessageMap.internalError))
|
|
14220
14220
|
},
|
|
14221
14221
|
status
|
|
14222
14222
|
);
|
|
@@ -14256,21 +14256,19 @@ var createTypedClient = () => {
|
|
|
14256
14256
|
_optionalChain([callbacks, 'optionalAccess', _194 => _194.onSuccess, 'optionalCall', _195 => _195(data, responseHeaders)]);
|
|
14257
14257
|
return data;
|
|
14258
14258
|
} catch (err) {
|
|
14259
|
-
const errorBody = { message: err.message };
|
|
14260
14259
|
let status = 500;
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
}
|
|
14271
|
-
_optionalChain([callbacks, 'optionalAccess',
|
|
14272
|
-
|
|
14273
|
-
throw new (0, _httpexception.HTTPException)(status, errorBody);
|
|
14260
|
+
const { detail, statusCode } = err;
|
|
14261
|
+
status = _nullishCoalesce(statusCode, () => ( 500));
|
|
14262
|
+
if (!detail) {
|
|
14263
|
+
_optionalChain([options, 'access', _196 => _196.errorHandler, 'optionalCall', _197 => _197(status, {
|
|
14264
|
+
message: "Fetch malformed"
|
|
14265
|
+
})]);
|
|
14266
|
+
throw new (0, _httpexception.HTTPException)(status, { message: "Fetch malformed" });
|
|
14267
|
+
}
|
|
14268
|
+
const { message } = detail;
|
|
14269
|
+
_optionalChain([options, 'access', _198 => _198.errorHandler, 'optionalCall', _199 => _199(status, { ...detail, status })]);
|
|
14270
|
+
_optionalChain([callbacks, 'optionalAccess', _200 => _200.onError, 'optionalCall', _201 => _201(detail, responseHeaders)]);
|
|
14271
|
+
throw new (0, _httpexception.HTTPException)(status, { message });
|
|
14274
14272
|
} finally {
|
|
14275
14273
|
_optionalChain([callbacks, 'optionalAccess', _202 => _202.onEnd, 'optionalCall', _203 => _203()]);
|
|
14276
14274
|
}
|