@beepbox.net/gofetch-client 0.1.2 → 0.2.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.
- package/README.md +26 -24
- package/dist/index.d.ts +10 -1
- package/dist/index.js +153 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Typesafe [Eden treaty](https://elysiajs.com/eden/overview) client for the [gofetch](https://gofetch.blaqat.net) API.
|
|
4
4
|
|
|
5
|
-
Route paths, query params, bodies, and responses are inferred from the server — no manual typing.
|
|
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
5
|
## Install
|
|
10
6
|
|
|
11
7
|
```bash
|
|
12
|
-
|
|
8
|
+
bun add @beepbox.net/gofetch-client
|
|
13
9
|
```
|
|
14
10
|
|
|
15
11
|
## Quick start
|
|
@@ -21,6 +17,31 @@ const api = createClient()
|
|
|
21
17
|
// defaults to https://gofetch.blaqat.net
|
|
22
18
|
```
|
|
23
19
|
|
|
20
|
+
## API docs
|
|
21
|
+
|
|
22
|
+
Live OpenAPI reference: https://gofetch.blaqat.net/docs
|
|
23
|
+
|
|
24
|
+
## Friendly fetcher
|
|
25
|
+
|
|
26
|
+
cuter wrapper over the normal client for better dev experience
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { createFetcher } from '@beepbox.net/gofetch-client'
|
|
30
|
+
// `createFetcher` accepts the same options as `createClient` (`baseUrl`, `token`).
|
|
31
|
+
|
|
32
|
+
const client = createFetcher()
|
|
33
|
+
|
|
34
|
+
const { data } = await client.util.resolveShortUrl('https://tinyurl.com/buwnpvpd')
|
|
35
|
+
console.log(data?.modName)
|
|
36
|
+
```
|
|
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
|
+
|
|
24
45
|
## Auth
|
|
25
46
|
|
|
26
47
|
Pass a JWT from Discord OAuth (`/v0/auth/discord` → callback):
|
|
@@ -71,21 +92,6 @@ const { data } = await api.v1.beep.get({
|
|
|
71
92
|
|
|
72
93
|
Public list works without auth (URLs hidden for guests). Authenticated callers see full fields.
|
|
73
94
|
|
|
74
|
-
## Resolve a short URL
|
|
75
|
-
|
|
76
|
-
`GET /v1/util/resolve/short` — follows redirects / meta-refresh / canonical links to a final BeepBox mod URL:
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
const { data } = await api.v1.util.resolve.short.get({
|
|
80
|
-
query: { url: 'https://tinyurl.com/your-link' },
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
// data.resolvedUrl, data.modName, data.modId
|
|
84
|
-
// data.steps? — hop-by-hop trace
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Related: `api.v1.util.resolve.platform.get({ query: { url } })` maps a song URL to a known platform.
|
|
88
|
-
|
|
89
95
|
## Custom base URL
|
|
90
96
|
|
|
91
97
|
```ts
|
|
@@ -94,7 +100,3 @@ const api = createClient({
|
|
|
94
100
|
token: optionalJwt,
|
|
95
101
|
})
|
|
96
102
|
```
|
|
97
|
-
|
|
98
|
-
## API docs
|
|
99
|
-
|
|
100
|
-
Live OpenAPI reference: https://gofetch.blaqat.net/docs
|