@firtoz/hono-fetcher 2.1.0 → 2.2.0
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/package.json +6 -6
- package/src/honoFetcher.ts +8 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firtoz/hono-fetcher",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Type-safe Hono API client with full TypeScript inference for routes, params, and payloads",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"module": "./src/index.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"README.md"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
-
"typecheck": "tsc --noEmit",
|
|
26
|
+
"typecheck": "tsc --noEmit -p ./tsconfig.json",
|
|
27
27
|
"lint": "biome check --write src",
|
|
28
28
|
"lint:ci": "biome ci src",
|
|
29
29
|
"format": "biome format src --write",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"url": "https://github.com/firtoz/fullstack-toolkit/issues"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@cloudflare/workers-types": "
|
|
56
|
-
"hono": "
|
|
55
|
+
"@cloudflare/workers-types": "catalog:",
|
|
56
|
+
"hono": "catalog:"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=18.0.0"
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@hono/node-server": "^1.19.5",
|
|
66
66
|
"@hono/zod-validator": "^0.7.4",
|
|
67
|
-
"bun-types": "
|
|
68
|
-
"zod": "
|
|
67
|
+
"bun-types": "catalog:",
|
|
68
|
+
"zod": "catalog:"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/honoFetcher.ts
CHANGED
|
@@ -122,7 +122,8 @@ export type TypedWebSocketFetcher<T extends Hono> = <
|
|
|
122
122
|
export type BaseTypedHonoFetcher<T extends Hono> = {
|
|
123
123
|
[M in AvailableMethods<T>]: TypedMethodFetcher<T, M>;
|
|
124
124
|
} & (keyof HonoSchema<T>["get"] extends never
|
|
125
|
-
?
|
|
125
|
+
? // biome-ignore lint/complexity/noBannedTypes: We really do want an empty object if the get method is not available
|
|
126
|
+
{}
|
|
126
127
|
: { websocket: TypedWebSocketFetcher<T> });
|
|
127
128
|
|
|
128
129
|
const createMethodFetcher = <T extends Hono, M extends HttpMethod>(
|
|
@@ -161,8 +162,9 @@ const createMethodFetcher = <T extends Hono, M extends HttpMethod>(
|
|
|
161
162
|
body = JSON.stringify(requestAsOptionalFormBody.body) as BodyInit;
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
const newHeaders = new Headers(
|
|
166
|
+
init.headers as unknown as ConstructorParameters<typeof Headers>[0],
|
|
167
|
+
);
|
|
166
168
|
|
|
167
169
|
if (body && !requestAsOptionalFormBody.form) {
|
|
168
170
|
newHeaders.set("Content-Type", "application/json");
|
|
@@ -200,8 +202,9 @@ const createWebSocketFetcher = <T extends Hono>(
|
|
|
200
202
|
}, finalUrl);
|
|
201
203
|
}
|
|
202
204
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
const newHeaders = new Headers(
|
|
206
|
+
init.headers as unknown as ConstructorParameters<typeof Headers>[0],
|
|
207
|
+
);
|
|
205
208
|
newHeaders.set("Upgrade", "websocket");
|
|
206
209
|
|
|
207
210
|
try {
|