@beepbox.net/gofetch-client 0.1.1 → 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 +30 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +153 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -19,6 +19,36 @@ const api = createClient()
|
|
|
19
19
|
// defaults to https://gofetch.blaqat.net
|
|
20
20
|
```
|
|
21
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
|
+
|
|
22
52
|
## Auth
|
|
23
53
|
|
|
24
54
|
Pass a JWT from Discord OAuth (`/v0/auth/discord` → callback):
|