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.d.cts
CHANGED
|
@@ -501,4 +501,4 @@ interface CreateTypedClientOptions {
|
|
|
501
501
|
}
|
|
502
502
|
declare const createTypedClient: <TApp extends Hono<any, any, any>>() => (options: CreateTypedClientOptions) => <TSuccessData>(fn: (c: ReturnType<typeof hc<TApp>>) => Promise<ClientResponse<TSuccessData>>, callbacks?: TypedClientCallbacks) => Promise<TSuccessData>;
|
|
503
503
|
|
|
504
|
-
export { type ContextFn, type CreateTypedClientOptions, type HonoClientInfoVariables, type HonoI18nVariables, type HonoIsBotVariables, type HonoLanguageVariables, type HonoLoggerVariables, type HonoResponseVariables, type MessageHandlers, pbkdf2 as PBKDF2, QueueHandler, sha as SHA, type WrappableMiddleware, clientInfo, createTypedClient, hydrateVariable, i18n, isBot, jsonValidator, logger, onError, onNotFound, queue, response, withLogger };
|
|
504
|
+
export { type ContextFn, type CreateTypedClientOptions, type HonoClientInfoVariables, type HonoI18nVariables, type HonoIsBotVariables, type HonoLanguageVariables, type HonoLoggerVariables, type HonoResponseVariables, type MessageHandlers, pbkdf2 as PBKDF2, QueueHandler, sha as SHA, type TypedClientCallbacks, type WrappableMiddleware, clientInfo, createTypedClient, hydrateVariable, i18n, isBot, jsonValidator, logger, onError, onNotFound, queue, response, withLogger };
|
package/dist/index.d.ts
CHANGED
|
@@ -501,4 +501,4 @@ interface CreateTypedClientOptions {
|
|
|
501
501
|
}
|
|
502
502
|
declare const createTypedClient: <TApp extends Hono<any, any, any>>() => (options: CreateTypedClientOptions) => <TSuccessData>(fn: (c: ReturnType<typeof hc<TApp>>) => Promise<ClientResponse<TSuccessData>>, callbacks?: TypedClientCallbacks) => Promise<TSuccessData>;
|
|
503
503
|
|
|
504
|
-
export { type ContextFn, type CreateTypedClientOptions, type HonoClientInfoVariables, type HonoI18nVariables, type HonoIsBotVariables, type HonoLanguageVariables, type HonoLoggerVariables, type HonoResponseVariables, type MessageHandlers, pbkdf2 as PBKDF2, QueueHandler, sha as SHA, type WrappableMiddleware, clientInfo, createTypedClient, hydrateVariable, i18n, isBot, jsonValidator, logger, onError, onNotFound, queue, response, withLogger };
|
|
504
|
+
export { type ContextFn, type CreateTypedClientOptions, type HonoClientInfoVariables, type HonoI18nVariables, type HonoIsBotVariables, type HonoLanguageVariables, type HonoLoggerVariables, type HonoResponseVariables, type MessageHandlers, pbkdf2 as PBKDF2, QueueHandler, sha as SHA, type TypedClientCallbacks, type WrappableMiddleware, clientInfo, createTypedClient, hydrateVariable, i18n, isBot, jsonValidator, logger, onError, onNotFound, queue, response, withLogger };
|
package/dist/index.js
CHANGED
|
@@ -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 parseError(err, env, get) ?? defaultMessageMap.internalError
|
|
14220
14220
|
},
|
|
14221
14221
|
status
|
|
14222
14222
|
);
|
|
@@ -14239,7 +14239,7 @@ var onNotFound = async (c) => {
|
|
|
14239
14239
|
|
|
14240
14240
|
// src/client/createTypedClient.ts
|
|
14241
14241
|
import { hc } from "hono/client";
|
|
14242
|
-
import { parseResponse
|
|
14242
|
+
import { parseResponse } from "hono/client";
|
|
14243
14243
|
import { HTTPException as HTTPException4 } from "hono/http-exception";
|
|
14244
14244
|
var createTypedClient = () => {
|
|
14245
14245
|
return (options) => async (fn, callbacks) => {
|
|
@@ -14256,21 +14256,19 @@ var createTypedClient = () => {
|
|
|
14256
14256
|
callbacks?.onSuccess?.(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
|
-
throw new HTTPException4(500, { message: "Fetch malformed" });
|
|
14269
|
-
}
|
|
14260
|
+
const { detail, statusCode } = err;
|
|
14261
|
+
status = statusCode ?? 500;
|
|
14262
|
+
if (!detail) {
|
|
14263
|
+
options.errorHandler?.(status, {
|
|
14264
|
+
message: "Fetch malformed"
|
|
14265
|
+
});
|
|
14266
|
+
throw new HTTPException4(status, { message: "Fetch malformed" });
|
|
14270
14267
|
}
|
|
14271
|
-
|
|
14272
|
-
options.errorHandler?.(status,
|
|
14273
|
-
|
|
14268
|
+
const { message } = detail;
|
|
14269
|
+
options.errorHandler?.(status, { ...detail, status });
|
|
14270
|
+
callbacks?.onError?.(detail, responseHeaders);
|
|
14271
|
+
throw new HTTPException4(status, { message });
|
|
14274
14272
|
} finally {
|
|
14275
14273
|
callbacks?.onEnd?.();
|
|
14276
14274
|
}
|