@beepbox.net/gofetch-client 0.2.1 → 0.2.3

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
@@ -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
- npm install @beepbox.net/gofetch-client @elysiajs/eden elysia
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
- Prefer short, namespaced methods over the full treaty path? Use `createFetcher`:
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,22 +42,20 @@ 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.
45
+ ## Auth
49
46
 
50
- `createFetcher` accepts the same options as `createClient` (`baseUrl`, `token`).
47
+ gofetch is a standalone API. Discord OAuth completes at `GET /v0/auth/discord/callback`, which returns JSON:
51
48
 
52
- ## Auth
49
+ ```json
50
+ { "accessToken": "<jwt>", "user": { ... } }
51
+ ```
53
52
 
54
- Pass a JWT from Discord OAuth (`/v0/auth/discord` callback):
53
+ Your app runs the login UX (redirect to `/v0/auth/discord`, handle the callback response, store the JWT). Then pass the token into the client:
55
54
 
56
55
  ```ts
57
- const api = createClient({ token: process.env.GOFETCH_TOKEN })
56
+ const api = createClient({ token: accessToken })
58
57
 
59
58
  const { data: me } = await api.v1.user.me.get()
60
- // me is fully typed (displayName, role, etc.)
61
59
  ```
62
60
 
63
61
  Per-request headers also work:
@@ -99,21 +97,6 @@ const { data } = await api.v1.beep.get({
99
97
 
100
98
  Public list works without auth (URLs hidden for guests). Authenticated callers see full fields.
101
99
 
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
100
  ## Custom base URL
118
101
 
119
102
  ```ts
@@ -122,7 +105,3 @@ const api = createClient({
122
105
  token: optionalJwt,
123
106
  })
124
107
  ```
125
-
126
- ## API docs
127
-
128
- Live OpenAPI reference: https://gofetch.blaqat.net/docs