hono-utils 0.3.2 → 0.3.4
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 +20 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -4
- package/dist/index.d.ts +26 -4
- package/dist/index.js +20 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13925,17 +13925,17 @@ var queue = ({
|
|
|
13925
13925
|
|
|
13926
13926
|
|
|
13927
13927
|
var setResponseHandlers = (c) => {
|
|
13928
|
-
const method = c.req.method;
|
|
13929
13928
|
return {
|
|
13930
13929
|
raw: (data) => {
|
|
13931
13930
|
const { status, ...rest } = data;
|
|
13932
13931
|
return c.json(rest, status || 200);
|
|
13933
13932
|
},
|
|
13934
13933
|
success: (message, data, status) => {
|
|
13935
|
-
const statusCode = status ||
|
|
13936
|
-
|
|
13937
|
-
|
|
13938
|
-
|
|
13934
|
+
const statusCode = status || 200;
|
|
13935
|
+
return c.json({ message, data }, statusCode);
|
|
13936
|
+
},
|
|
13937
|
+
successNoContent: (message, status) => {
|
|
13938
|
+
const statusCode = status || 200;
|
|
13939
13939
|
return c.json({ message }, statusCode);
|
|
13940
13940
|
},
|
|
13941
13941
|
error: (message, status) => {
|
|
@@ -13953,7 +13953,9 @@ var setResponseHandlers = (c) => {
|
|
|
13953
13953
|
};
|
|
13954
13954
|
var response = _factory.createMiddleware.call(void 0, async (c, next) => {
|
|
13955
13955
|
c.set("res", setResponseHandlers(c));
|
|
13956
|
-
|
|
13956
|
+
if (c.var.eventId) {
|
|
13957
|
+
c.header("x-event-id", c.var.eventId);
|
|
13958
|
+
}
|
|
13957
13959
|
await next();
|
|
13958
13960
|
});
|
|
13959
13961
|
|
|
@@ -14239,19 +14241,19 @@ var onNotFound = async (c) => {
|
|
|
14239
14241
|
var _client = require('hono/client');
|
|
14240
14242
|
|
|
14241
14243
|
|
|
14242
|
-
var createTypedClient = (
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
_optionalChain([
|
|
14244
|
+
var createTypedClient = () => {
|
|
14245
|
+
return (options) => async (fn, callbacks) => {
|
|
14246
|
+
const client = _client.hc.call(void 0, options.url, {
|
|
14247
|
+
headers: options.headers,
|
|
14248
|
+
fetch: options.fetch
|
|
14249
|
+
});
|
|
14250
|
+
_optionalChain([callbacks, 'optionalAccess', _192 => _192.onStart, 'optionalCall', _193 => _193()]);
|
|
14249
14251
|
let responseHeaders = new Headers();
|
|
14250
14252
|
try {
|
|
14251
14253
|
const response2 = await fn(client);
|
|
14252
14254
|
responseHeaders = response2.headers;
|
|
14253
14255
|
const data = await _client.parseResponse.call(void 0, response2);
|
|
14254
|
-
_optionalChain([
|
|
14256
|
+
_optionalChain([callbacks, 'optionalAccess', _194 => _194.onSuccess, 'optionalCall', _195 => _195(data, responseHeaders)]);
|
|
14255
14257
|
return data;
|
|
14256
14258
|
} catch (err) {
|
|
14257
14259
|
const errorBody = { message: err.message };
|
|
@@ -14260,20 +14262,19 @@ var createTypedClient = (options) => {
|
|
|
14260
14262
|
const { detail, statusCode } = err;
|
|
14261
14263
|
status = _nullishCoalesce(statusCode, () => ( 500));
|
|
14262
14264
|
if (!detail) {
|
|
14263
|
-
_optionalChain([
|
|
14265
|
+
_optionalChain([callbacks, 'optionalAccess', _196 => _196.errorHandler, 'optionalCall', _197 => _197(500, {
|
|
14264
14266
|
message: "Fetch malformed"
|
|
14265
14267
|
})]);
|
|
14266
14268
|
throw new (0, _httpexception.HTTPException)(500, { message: "Fetch malformed" });
|
|
14267
14269
|
}
|
|
14268
14270
|
}
|
|
14269
|
-
_optionalChain([
|
|
14270
|
-
_optionalChain([
|
|
14271
|
+
_optionalChain([callbacks, 'optionalAccess', _198 => _198.onError, 'optionalCall', _199 => _199(errorBody, responseHeaders)]);
|
|
14272
|
+
_optionalChain([callbacks, 'optionalAccess', _200 => _200.errorHandler, 'optionalCall', _201 => _201(status, errorBody)]);
|
|
14271
14273
|
throw new (0, _httpexception.HTTPException)(status, errorBody);
|
|
14272
14274
|
} finally {
|
|
14273
|
-
_optionalChain([
|
|
14275
|
+
_optionalChain([callbacks, 'optionalAccess', _202 => _202.onEnd, 'optionalCall', _203 => _203()]);
|
|
14274
14276
|
}
|
|
14275
14277
|
};
|
|
14276
|
-
return rpcClient;
|
|
14277
14278
|
};
|
|
14278
14279
|
|
|
14279
14280
|
|