Skip to content

Commit 9ca63fd

Browse files
committed
Setup
1 parent 303152a commit 9ca63fd

File tree

6 files changed

+231
-0
lines changed

6 files changed

+231
-0
lines changed

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store

README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Devup API
2+
3+
**A fully typed API client generator powered by OpenAPI.
4+
Fetch-compatible, auto-generated types, zero generics required.**
5+
6+
Devup API reads your `openapi.json` file and automatically generates a fully typed client that behaves like an ergonomic, type-safe version of `fetch()`.
7+
No manual type declarations. No generics. No SDK boilerplate.
8+
Just write API calls — the types are already there.
9+
10+
---
11+
12+
## ✨ Features
13+
14+
### **🔍 OpenAPI-driven type generation**
15+
- Reads `openapi.json` and transforms every path, method, schema into typed API functions.
16+
- Parameters, request bodies, headers, responses — all typed automatically.
17+
- No need to write or maintain separate TypeScript definitions.
18+
19+
### **🪝 Fetch-compatible design**
20+
Devup API feels like using `fetch`, but with superpowers:
21+
22+
- Path params automatically replaced
23+
- Query/body/header types enforced
24+
- Typed success & error responses
25+
- Optional runtime schema validation
26+
- Minimal abstraction over standard fetch
27+
28+
---
29+
30+
## 🚀 Quick Start
31+
32+
### **1. Initialize the client**
33+
34+
```ts
35+
import { devupApi } from "devup-api";
36+
37+
// create api instance
38+
const api = await devupApi("https://api.example.com");
39+
```
40+
41+
### **2. Call endpoints — types are automatic**
42+
43+
```ts
44+
const user = await api.get("/users/{id}", {
45+
params: { id: "123" },
46+
headers: {
47+
Authorization: "Bearer TOKEN"
48+
}
49+
});
50+
51+
const user = await api.get("getUser", {
52+
params: { id: "123" },
53+
headers: {
54+
Authorization: "Bearer TOKEN"
55+
}
56+
});
57+
```
58+
59+
---
60+
61+
## 📦 Installation
62+
63+
```bash
64+
npm install @devup-api/fetch
65+
66+
npm install @devup-api/next-plugin
67+
npm install @devup-api/webpack-plugin
68+
npm install @devup-api/rsbuild-plugin
69+
npm install @devup-api/vite-plugin
70+
```
71+
72+
---
73+
74+
## 📚 API Usage
75+
76+
### **GET Example**
77+
78+
```ts
79+
await api.get("/posts", {
80+
query: { page: 1, limit: 20 }
81+
});
82+
```
83+
84+
### **POST Example**
85+
86+
```ts
87+
await api.post("/posts", {
88+
body: {
89+
title: "Hello World",
90+
content: "This is a typed API request."
91+
}
92+
});
93+
```
94+
95+
### **Path Params Example**
96+
97+
```ts
98+
await api.get("/posts/{id}", {
99+
params: { id: "777" }
100+
});
101+
```
102+
103+
---
104+
105+
## ⚙️ How It Works
106+
107+
1. Download `openapi.json`
108+
2. Extract paths, methods, schemas, parameters, bodies
109+
3. Generate TypeScript types automatically
110+
4. Build a typed wrapper around `fetch()`
111+
5. Expose methods based on the API structure
112+
113+
---
114+
115+
## 🎯 Why Devup API?
116+
117+
- No code generators
118+
- No build steps
119+
- No boilerplate
120+
- Uses OpenAPI schema directly
121+
- Works in Next.js, Bun, Vite, rsbuild
122+
123+
---
124+
125+
## 🛠️ Roadmap
126+
127+
- [ ] Typescript interface generation
128+
- [ ] Zod schema generation
129+
130+
---
131+
132+
## 📄 License
133+
134+
Apache 2.0

bun.lock

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"lockfileVersion": 1,
3+
"configVersion": 1,
4+
"workspaces": {
5+
"": {
6+
"name": "devup-api",
7+
"devDependencies": {
8+
"@types/bun": "latest",
9+
},
10+
},
11+
},
12+
"packages": {
13+
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.3.3" } }, "sha512-ogrKbJ2X5N0kWLLFKeytG0eHDleBYtngtlbu9cyBKFtNL3cnpDZkNdQj8flVf6WTZUX5ulI9AY1oa7ljhSrp+g=="],
14+
15+
"@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="],
16+
17+
"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-z3Xwlg7j2l9JY27x5Qn3Wlyos8YAp0kKRlrePAOjgjMGS5IG6E7Jnlx736vH9UVI4wUICwwhC9anYL++XeOgTQ=="],
18+
19+
"undici-types": ["[email protected]", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
20+
}
21+
}

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Hello via Bun!");

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "devup-api",
3+
"module": "index.ts",
4+
"type": "module",
5+
"private": true,
6+
"devDependencies": {
7+
"@types/bun": "latest"
8+
},
9+
"workspaces": [
10+
"packages/*"
11+
]
12+
}

tsconfig.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
// Environment setup & latest features
4+
"lib": ["ESNext"],
5+
"target": "ESNext",
6+
"module": "Preserve",
7+
"moduleDetection": "force",
8+
"jsx": "react-jsx",
9+
"allowJs": true,
10+
11+
// Bundler mode
12+
"moduleResolution": "bundler",
13+
"allowImportingTsExtensions": true,
14+
"verbatimModuleSyntax": true,
15+
"noEmit": true,
16+
17+
// Best practices
18+
"strict": true,
19+
"skipLibCheck": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedIndexedAccess": true,
22+
"noImplicitOverride": true,
23+
24+
// Some stricter flags (disabled by default)
25+
"noUnusedLocals": false,
26+
"noUnusedParameters": false,
27+
"noPropertyAccessFromIndexSignature": false
28+
}
29+
}

0 commit comments

Comments
 (0)