@beepbox.net/gofetch-client 0.1.2 → 0.2.1

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 CHANGED
@@ -4,8 +4,6 @@ Typesafe [Eden treaty](https://elysiajs.com/eden/overview) client for the [gofet
4
4
 
5
5
  Route paths, query params, bodies, and responses are inferred from the server — no manual typing.
6
6
 
7
- Eden Treaty types request params from validator **output** (after arktype morphs). This package applies `MapTreatyClientWire` plus generated wire patches so query/body/header inputs match HTTP (`string` URLs, `'true' | 'false'`, `limit` as `number | string`, opaque `cursor` strings, etc.) while server handlers still receive parsed types. Run `bun run build:types` after API schema changes; `validate-wire-output` fails the build if morph output types leak into requests.
8
-
9
7
  ## Install
10
8
 
11
9
  ```bash
@@ -21,6 +19,36 @@ const api = createClient()
21
19
  // defaults to https://gofetch.blaqat.net
22
20
  ```
23
21
 
22
+ ## Friendly fetcher
23
+
24
+ Prefer short, namespaced methods over the full treaty path? Use `createFetcher`:
25
+
26
+ ```ts
27
+ import { createFetcher } from '@beepbox.net/gofetch-client'
28
+
29
+ const client = createFetcher()
30
+
31
+ const { data } = await client.util.resolveShortUrl('https://tinyurl.com/buwnpvpd')
32
+ console.log(data?.modName)
33
+ ```
34
+
35
+ It wraps the same treaty client — every method maps directly to a route and keeps
36
+ the generated request/response types:
37
+
38
+ ```ts
39
+ await client.beep.list({ songType: 'Original', limit: 20 })
40
+ await client.beep.get(id)
41
+ await client.event.removeHost(eventId, userId)
42
+ await client.user.me({ headers: { Authorization: `Bearer ${token}` } })
43
+ ```
44
+
45
+ Methods are grouped by namespace: `beep`, `event`, `platform`, `source`, `forum`,
46
+ `submission`, `weightGroup`, `xp`, `user`, `util`. Every method takes an optional
47
+ trailing `opts` (`{ headers }`) for per-request auth. The raw treaty client is
48
+ always reachable via `client.raw` as an escape hatch.
49
+
50
+ `createFetcher` accepts the same options as `createClient` (`baseUrl`, `token`).
51
+
24
52
  ## Auth
25
53
 
26
54
  Pass a JWT from Discord OAuth (`/v0/auth/discord` → callback):