Skip to content

Commit 13eb7ef

Browse files
feat: add generated TypeScript client
0 parents  commit 13eb7ef

27 files changed

Lines changed: 10144 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: oven-sh/setup-bun@v2
14+
with:
15+
bun-version: latest
16+
- run: bun install --frozen-lockfile
17+
- run: bun run check
18+
- run: bun run build
19+
- run: bun run pack:check

.github/workflows/publish.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
npm:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: oven-sh/setup-bun@v2
17+
with:
18+
bun-version: latest
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 24
22+
registry-url: https://registry.npmjs.org
23+
- run: bun install --frozen-lockfile
24+
- run: bun run build
25+
- run: npm publish --provenance --access public

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
.env
4+
.env.*
5+
*.tgz

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 EnderDash
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# EnderDash Client
2+
3+
TypeScript client for the EnderDash HTTP API.
4+
5+
The client is generated from EnderDash's OpenAPI document and configured for the tRPC HTTP protocol. It uses `superjson`, matching the EnderDash API transformer.
6+
7+
## Install
8+
9+
```bash
10+
bun add @enderdash/client
11+
```
12+
13+
## Usage
14+
15+
```ts
16+
import { createEnderDashClient } from "@enderdash/client";
17+
18+
const enderdash = createEnderDashClient({
19+
apiKey: process.env.ENDERDASH_API_KEY,
20+
});
21+
22+
const servers = await enderdash.servers.listServers({
23+
query: {
24+
input: {
25+
organizationSlug: "test",
26+
},
27+
},
28+
});
29+
```
30+
31+
Pass `baseUrl` when targeting a local or self-hosted EnderDash app:
32+
33+
```ts
34+
const enderdash = createEnderDashClient({
35+
apiKey: process.env.ENDERDASH_API_KEY,
36+
baseUrl: "https://app.enderdash.localhost:1355/api/trpc",
37+
});
38+
```
39+
40+
## Regenerate
41+
42+
```bash
43+
bun run generate
44+
```
45+
46+
By default, generation uses `https://app.enderdash.com/openapi.json`.
47+
48+
To generate from another spec:
49+
50+
```bash
51+
ENDERDASH_OPENAPI_SPEC=./openapi.json bun run generate
52+
```
53+
54+
## Development
55+
56+
```bash
57+
bun install
58+
bun run generate
59+
bun run check
60+
bun run build
61+
```
62+
63+
## Publishing
64+
65+
Publishing runs from GitHub releases through `.github/workflows/publish.yml`.
66+
67+
The workflow uses npm provenance and GitHub's OpenID Connect token. Before the first release, configure npm trusted publishing for `@enderdash/client` with:
68+
69+
- owner: `enderdash-com`
70+
- repository: `enderdash-client`
71+
- workflow: `publish.yml`
72+
73+
Then publish by creating a GitHub release for the version in `package.json`.

bun.lock

Lines changed: 146 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "@enderdash/client",
3+
"version": "0.1.0",
4+
"description": "TypeScript client for the EnderDash HTTP API.",
5+
"type": "module",
6+
"license": "MIT",
7+
"packageManager": "bun@1.3.14",
8+
"engines": {
9+
"node": ">=22"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/enderdash-com/enderdash-client.git"
14+
},
15+
"bugs": {
16+
"url": "https://github.com/enderdash-com/enderdash-client/issues"
17+
},
18+
"homepage": "https://github.com/enderdash-com/enderdash-client#readme",
19+
"files": [
20+
"dist"
21+
],
22+
"exports": {
23+
".": {
24+
"types": "./dist/index.d.ts",
25+
"import": "./dist/index.js"
26+
}
27+
},
28+
"main": "./dist/index.js",
29+
"types": "./dist/index.d.ts",
30+
"scripts": {
31+
"build": "tsc -p tsconfig.build.json",
32+
"check": "tsc --noEmit",
33+
"generate": "bun scripts/generate.ts",
34+
"pack:check": "bun pm pack --dry-run",
35+
"prepack": "bun run build"
36+
},
37+
"dependencies": {
38+
"@hey-api/client-fetch": "^0.13.1",
39+
"@trpc/openapi": "11.17.0-alpha",
40+
"superjson": "^2.2.6"
41+
},
42+
"devDependencies": {
43+
"@hey-api/openapi-ts": "^0.97.3",
44+
"@types/node": "^25.9.1",
45+
"typescript": "^6.0.3"
46+
},
47+
"peerDependencies": {
48+
"typescript": ">=5.8"
49+
},
50+
"peerDependenciesMeta": {
51+
"typescript": {
52+
"optional": true
53+
}
54+
},
55+
"publishConfig": {
56+
"access": "public"
57+
}
58+
}

scripts/generate.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createClient } from "@hey-api/openapi-ts";
2+
import { createTRPCHeyApiTypeResolvers } from "@trpc/openapi/heyapi";
3+
4+
const input =
5+
process.env.ENDERDASH_OPENAPI_SPEC ?? "https://app.enderdash.com/openapi.json";
6+
7+
await createClient({
8+
input,
9+
output: "src/generated",
10+
plugins: [
11+
{
12+
name: "@hey-api/typescript",
13+
"~resolvers": createTRPCHeyApiTypeResolvers(),
14+
},
15+
"@hey-api/client-fetch",
16+
{
17+
name: "@hey-api/sdk",
18+
operations: { strategy: "single" },
19+
},
20+
],
21+
});

src/generated/client.gen.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
3+
import { type ClientOptions, type Config, createClient, createConfig } from './client/index.js';
4+
import type { ClientOptions as ClientOptions2 } from './types.gen.js';
5+
6+
/**
7+
* The `createClientConfig()` function will be called on client initialization
8+
* and the returned object will become the client's initial configuration.
9+
*
10+
* You may want to initialize your client this way instead of calling
11+
* `setConfig()`. This is useful for example if you're using Next.js
12+
* to ensure your client always has the correct values.
13+
*/
14+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
15+
16+
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'https://app.enderdash.com/api/trpc' }));

0 commit comments

Comments
 (0)