@firtoz/hono-fetcher 1.1.0 → 2.0.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/README.md +8 -6
- package/package.json +3 -3
- package/src/honoDoFetcher.ts +1 -1
package/README.md
CHANGED
|
@@ -29,12 +29,14 @@ This package requires the following peer dependencies:
|
|
|
29
29
|
bun add hono
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
For Durable Object support:
|
|
32
|
+
For Durable Object support, use `wrangler types` to generate accurate types:
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
|
|
35
|
+
wrangler types
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
This generates `worker-configuration.d.ts` with types for your specific environment bindings.
|
|
39
|
+
|
|
38
40
|
## Quick Start
|
|
39
41
|
|
|
40
42
|
### Basic Usage
|
|
@@ -129,11 +131,11 @@ export class ChatRoomDO extends DurableObject {
|
|
|
129
131
|
// In your worker
|
|
130
132
|
export default {
|
|
131
133
|
async fetch(request: Request, env: Env): Promise<Response> {
|
|
132
|
-
// Option 1: From a stub
|
|
133
|
-
const stub = env.CHAT_ROOM.
|
|
134
|
+
// Option 1: From a stub (using new getByName API)
|
|
135
|
+
const stub = env.CHAT_ROOM.getByName('room-1');
|
|
134
136
|
const api = honoDoFetcher(stub);
|
|
135
137
|
|
|
136
|
-
// Option 2: Directly with name
|
|
138
|
+
// Option 2: Directly with name (recommended)
|
|
137
139
|
const api2 = honoDoFetcherWithName(env.CHAT_ROOM, 'room-1');
|
|
138
140
|
|
|
139
141
|
// Use it!
|
|
@@ -303,7 +305,7 @@ await api.get({
|
|
|
303
305
|
Creates a typed fetcher for a Durable Object stub.
|
|
304
306
|
|
|
305
307
|
```typescript
|
|
306
|
-
const stub = env.MY_DO.
|
|
308
|
+
const stub = env.MY_DO.getByName('example');
|
|
307
309
|
const api = honoDoFetcher(stub);
|
|
308
310
|
|
|
309
311
|
await api.get({ url: '/status' });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firtoz/hono-fetcher",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@hono/node-server": "^1.19.5",
|
|
66
|
-
"@hono/zod-validator": "^0.7.
|
|
67
|
-
"bun-types": "^1.
|
|
66
|
+
"@hono/zod-validator": "^0.7.4",
|
|
67
|
+
"bun-types": "^1.3.0",
|
|
68
68
|
"zod": "^4.1.12"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/honoDoFetcher.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const honoDoFetcherWithName = <
|
|
|
44
44
|
namespace: DurableObjectNamespace<T>,
|
|
45
45
|
name: string,
|
|
46
46
|
): TypedDoFetcher<DurableObjectStub<T>> => {
|
|
47
|
-
return honoDoFetcher(namespace.
|
|
47
|
+
return honoDoFetcher(namespace.getByName(name));
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export const honoDoFetcherWithId = <
|