@beepbox.net/gofetch-client 0.2.1 → 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 +7 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,12 +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
5
|
## Install
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
|
|
8
|
+
bun add @beepbox.net/gofetch-client
|
|
11
9
|
```
|
|
12
10
|
|
|
13
11
|
## Quick start
|
|
@@ -19,12 +17,17 @@ const api = createClient()
|
|
|
19
17
|
// defaults to https://gofetch.blaqat.net
|
|
20
18
|
```
|
|
21
19
|
|
|
20
|
+
## API docs
|
|
21
|
+
|
|
22
|
+
Live OpenAPI reference: https://gofetch.blaqat.net/docs
|
|
23
|
+
|
|
22
24
|
## Friendly fetcher
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
cuter wrapper over the normal client for better dev experience
|
|
25
27
|
|
|
26
28
|
```ts
|
|
27
29
|
import { createFetcher } from '@beepbox.net/gofetch-client'
|
|
30
|
+
// `createFetcher` accepts the same options as `createClient` (`baseUrl`, `token`).
|
|
28
31
|
|
|
29
32
|
const client = createFetcher()
|
|
30
33
|
|
|
@@ -32,9 +35,6 @@ const { data } = await client.util.resolveShortUrl('https://tinyurl.com/buwnpvpd
|
|
|
32
35
|
console.log(data?.modName)
|
|
33
36
|
```
|
|
34
37
|
|
|
35
|
-
It wraps the same treaty client — every method maps directly to a route and keeps
|
|
36
|
-
the generated request/response types:
|
|
37
|
-
|
|
38
38
|
```ts
|
|
39
39
|
await client.beep.list({ songType: 'Original', limit: 20 })
|
|
40
40
|
await client.beep.get(id)
|
|
@@ -42,13 +42,6 @@ await client.event.removeHost(eventId, userId)
|
|
|
42
42
|
await client.user.me({ headers: { Authorization: `Bearer ${token}` } })
|
|
43
43
|
```
|
|
44
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
|
-
|
|
52
45
|
## Auth
|
|
53
46
|
|
|
54
47
|
Pass a JWT from Discord OAuth (`/v0/auth/discord` → callback):
|
|
@@ -99,21 +92,6 @@ const { data } = await api.v1.beep.get({
|
|
|
99
92
|
|
|
100
93
|
Public list works without auth (URLs hidden for guests). Authenticated callers see full fields.
|
|
101
94
|
|
|
102
|
-
## Resolve a short URL
|
|
103
|
-
|
|
104
|
-
`GET /v1/util/resolve/short` — follows redirects / meta-refresh / canonical links to a final BeepBox mod URL:
|
|
105
|
-
|
|
106
|
-
```ts
|
|
107
|
-
const { data } = await api.v1.util.resolve.short.get({
|
|
108
|
-
query: { url: 'https://tinyurl.com/your-link' },
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
// data.resolvedUrl, data.modName, data.modId
|
|
112
|
-
// data.steps? — hop-by-hop trace
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Related: `api.v1.util.resolve.platform.get({ query: { url } })` maps a song URL to a known platform.
|
|
116
|
-
|
|
117
95
|
## Custom base URL
|
|
118
96
|
|
|
119
97
|
```ts
|
|
@@ -122,7 +100,3 @@ const api = createClient({
|
|
|
122
100
|
token: optionalJwt,
|
|
123
101
|
})
|
|
124
102
|
```
|
|
125
|
-
|
|
126
|
-
## API docs
|
|
127
|
-
|
|
128
|
-
Live OpenAPI reference: https://gofetch.blaqat.net/docs
|