@beepbox.net/gofetch-client 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +98 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @beepbox.net/gofetch-client
2
+
3
+ Typesafe [Eden treaty](https://elysiajs.com/eden/overview) client for the [gofetch](https://gofetch.blaqat.net) API.
4
+
5
+ Route paths, query params, bodies, and responses are inferred from the server — no manual typing.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @beepbox.net/gofetch-client @elysiajs/eden elysia
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ts
16
+ import { createClient } from '@beepbox.net/gofetch-client'
17
+
18
+ const api = createClient()
19
+ // defaults to https://gofetch.blaqat.net
20
+ ```
21
+
22
+ ## Auth
23
+
24
+ Pass a JWT from Discord OAuth (`/v0/auth/discord` → callback):
25
+
26
+ ```ts
27
+ const api = createClient({ token: process.env.GOFETCH_TOKEN })
28
+
29
+ const { data: me } = await api.v1.user.me.get()
30
+ // me is fully typed (displayName, role, etc.)
31
+ ```
32
+
33
+ Per-request headers also work:
34
+
35
+ ```ts
36
+ await api.v1.beep.post(body, {
37
+ headers: { Authorization: `Bearer ${token}` },
38
+ })
39
+ ```
40
+
41
+ **Test server** (`NODE_ENV=test`): use `x-test-api-key` with a seeded user id instead of a JWT:
42
+
43
+ ```ts
44
+ const api = createClient({ baseUrl: 'http://localhost:3001' })
45
+
46
+ await api.v1.user.me.get({
47
+ headers: { 'x-test-api-key': 'seed-user-admin' },
48
+ })
49
+ ```
50
+
51
+ ## List / filter beeps
52
+
53
+ `GET /v1/beep` — filter by author, platform, song type, state, etc.:
54
+
55
+ ```ts
56
+ const { data } = await api.v1.beep.get({
57
+ query: {
58
+ userId: 'some-user-id',
59
+ songType: 'Original',
60
+ state: 'Complete',
61
+ limit: 20,
62
+ expand: ['authors', 'platforms'],
63
+ },
64
+ })
65
+
66
+ // data.data → beeps
67
+ // data.nextCursor → pagination cursor
68
+ ```
69
+
70
+ Public list works without auth (URLs hidden for guests). Authenticated callers see full fields.
71
+
72
+ ## Resolve a short URL
73
+
74
+ `GET /v1/util/resolve/short` — follows redirects / meta-refresh / canonical links to a final BeepBox mod URL:
75
+
76
+ ```ts
77
+ const { data } = await api.v1.util.resolve.short.get({
78
+ query: { url: 'https://tinyurl.com/your-link' },
79
+ })
80
+
81
+ // data.resolvedUrl, data.modName, data.modId
82
+ // data.steps? — hop-by-hop trace
83
+ ```
84
+
85
+ Related: `api.v1.util.resolve.platform.get({ query: { url } })` maps a song URL to a known platform.
86
+
87
+ ## Custom base URL
88
+
89
+ ```ts
90
+ const api = createClient({
91
+ baseUrl: 'https://gofetch.blaqat.net',
92
+ token: optionalJwt,
93
+ })
94
+ ```
95
+
96
+ ## API docs
97
+
98
+ Live OpenAPI reference: https://gofetch.blaqat.net/docs
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@beepbox.net/gofetch-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Typesafe Eden treaty client for the gofetch API",
5
5
  "license": "UNLICENSED",
6
6
  "files": [
7
- "dist"
7
+ "dist",
8
+ "README.md"
8
9
  ],
9
10
  "type": "module",
10
11
  "main": "./dist/index.js",