@umituz/web-hono 1.20.1 → 1.20.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/client.ts +11 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-hono",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
4
4
  "description": "API backend platform for Cloudflare Workers + Neon Postgres: createApi skeleton + error envelope layer, full-CRUD resource factory (opt-in create/remove, list params), schema→client type bridge (ClientRow), apiFetch/apiWrite client, reactive fetch-backed store (+React hooks), doc-sync diff/snapshot/push machine (snapshotDocs/diffOps/pushOps), better-auth server integration (tables/getter/mount/session helpers), weak-compare If-None-Match matcher (matchesEtag), cookie channels + request scope/ETag/R2-stream server helpers, TTL resource cache, and db lifecycle scripts (reset / snapshot / seed)",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/client.ts CHANGED
@@ -17,11 +17,19 @@ export class ApiClientError extends Error {
17
17
  }
18
18
  }
19
19
 
20
- export async function apiFetch<T>(path: string, init: { method?: 'POST' | 'PATCH' | 'PUT' | 'DELETE'; json?: unknown } = {}): Promise<T> {
20
+ export async function apiFetch<T>(
21
+ path: string,
22
+ init: { method?: 'POST' | 'PATCH' | 'PUT' | 'DELETE'; json?: unknown; form?: FormData } = {},
23
+ ): Promise<T> {
21
24
  const res = await fetch(path, {
22
25
  method: init.method ?? 'GET',
23
- headers: init.json !== undefined ? { 'content-type': 'application/json', accept: 'application/json' } : { accept: 'application/json' },
24
- body: init.json !== undefined ? JSON.stringify(init.json) : undefined,
26
+ headers:
27
+ init.form !== undefined || init.json !== undefined
28
+ ? init.form !== undefined
29
+ ? { accept: 'application/json' }
30
+ : { 'content-type': 'application/json', accept: 'application/json' }
31
+ : { accept: 'application/json' },
32
+ body: init.form !== undefined ? init.form : init.json !== undefined ? JSON.stringify(init.json) : undefined,
25
33
  });
26
34
  if (!res.ok) {
27
35
  const body = (await res.json().catch(() => null)) as { error?: string } | null;