bffgen 2.1.0 → 2.2.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.
- package/README.md +79 -3
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# bffgen
|
|
2
2
|
|
|
3
|
-
**Backend-for-Frontend (BFF) generator** - Scaffold secure, production-ready BFF services in **Go**, **Node.js (Express)**,
|
|
3
|
+
**Backend-for-Frontend (BFF) generator** - Scaffold secure, production-ready BFF services in **Go**, **Node.js (Express)**, **Node.js (Fastify)**, or **Python (FastAPI)** with JWT auth, rate limiting, CORS, and comprehensive logging.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/bffgen)
|
|
6
6
|
[](https://www.npmjs.com/package/bffgen)
|
|
@@ -20,9 +20,19 @@ npm install && npm run dev
|
|
|
20
20
|
|
|
21
21
|
# Create Fastify BFF
|
|
22
22
|
npx bffgen init my-fastify-bff --lang nodejs-fastify
|
|
23
|
+
cd my-fastify-bff
|
|
24
|
+
npm install && npm run dev
|
|
25
|
+
|
|
26
|
+
# Create FastAPI BFF (Python)
|
|
27
|
+
npx bffgen init my-python-bff --lang python-fastapi
|
|
28
|
+
cd my-python-bff
|
|
29
|
+
./setup.sh && source venv/bin/activate
|
|
30
|
+
uvicorn main:app --reload
|
|
23
31
|
|
|
24
32
|
# Create Go BFF
|
|
25
33
|
npx bffgen init my-go-bff --lang go --framework chi
|
|
34
|
+
cd my-go-bff
|
|
35
|
+
go run main.go
|
|
26
36
|
```
|
|
27
37
|
|
|
28
38
|
### Global Installation
|
|
@@ -44,6 +54,7 @@ cd my-project && npm run dev
|
|
|
44
54
|
|
|
45
55
|
- **Node.js Express** - Popular, flexible web framework
|
|
46
56
|
- **Node.js Fastify** - Fast, schema-based framework
|
|
57
|
+
- **Python FastAPI** - Modern, async-first web framework with automatic OpenAPI docs
|
|
47
58
|
- **Go (Chi/Echo/Fiber)** - High-performance, compiled servers
|
|
48
59
|
|
|
49
60
|
### 🚀 **Production-Ready Aggregation**
|
|
@@ -71,8 +82,10 @@ cd my-project && npm run dev
|
|
|
71
82
|
- **Hot Reload** - Development mode with auto-restart
|
|
72
83
|
- **Comprehensive Tests** - Jest setup with sample tests
|
|
73
84
|
|
|
74
|
-
### ⚡ **v2.
|
|
85
|
+
### ⚡ **v2.2 Enhancements** (NEW - Python Support!)
|
|
75
86
|
|
|
87
|
+
- **Python FastAPI Support** - Full async/await support with Pydantic validation
|
|
88
|
+
- **Type-Safe Python Models** - Pydantic models for request/response validation
|
|
76
89
|
- **Idempotent Generation** - Safe to run `generate` multiple times
|
|
77
90
|
- **Config Validation** - `bffgen config validate` catches errors pre-generation
|
|
78
91
|
- **Colorized Diffs** - Preview changes with `--dry-run`
|
|
@@ -135,6 +148,38 @@ bffgen version
|
|
|
135
148
|
|
|
136
149
|
## 📚 Examples
|
|
137
150
|
|
|
151
|
+
### Python FastAPI Example (NEW!)
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Create project
|
|
155
|
+
npx bffgen init my-python-bff --lang python-fastapi
|
|
156
|
+
|
|
157
|
+
# Project structure:
|
|
158
|
+
my-python-bff/
|
|
159
|
+
├── main.py # FastAPI application
|
|
160
|
+
├── config.py # Settings and configuration
|
|
161
|
+
├── dependencies.py # FastAPI dependency injection
|
|
162
|
+
├── routers/ # API route handlers (auto-generated)
|
|
163
|
+
├── services/ # Backend service clients (auto-generated)
|
|
164
|
+
├── models/ # Pydantic data models
|
|
165
|
+
├── middleware/ # Auth, logging middleware
|
|
166
|
+
├── utils/ # Utilities (logger, cache, circuit breaker)
|
|
167
|
+
├── tests/ # Pytest configuration and tests
|
|
168
|
+
├── .env # Environment variables
|
|
169
|
+
├── requirements.txt # Python dependencies
|
|
170
|
+
├── bffgen.config.py.json # BFF configuration
|
|
171
|
+
└── setup.sh # Setup script
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Quick Start:**
|
|
175
|
+
```bash
|
|
176
|
+
cd my-python-bff
|
|
177
|
+
./setup.sh # Create venv and install deps
|
|
178
|
+
source venv/bin/activate
|
|
179
|
+
uvicorn main:app --reload
|
|
180
|
+
# Visit http://localhost:8000/docs for Swagger UI
|
|
181
|
+
```
|
|
182
|
+
|
|
138
183
|
### Node.js Express Example
|
|
139
184
|
|
|
140
185
|
```bash
|
|
@@ -163,7 +208,38 @@ my-express-bff/
|
|
|
163
208
|
└── bffgen.config.json # BFF configuration
|
|
164
209
|
```
|
|
165
210
|
|
|
166
|
-
### Aggregation Example (v2.
|
|
211
|
+
### Aggregation Example - Python FastAPI (v2.2)
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
from fastapi import APIRouter, Depends
|
|
215
|
+
from services.tmdb_service import TMDBService
|
|
216
|
+
from services.users_service import UsersService
|
|
217
|
+
|
|
218
|
+
router = APIRouter()
|
|
219
|
+
tmdb = TMDBService()
|
|
220
|
+
users = UsersService()
|
|
221
|
+
|
|
222
|
+
@router.get("/api/dashboard/feed")
|
|
223
|
+
async def get_personalized_feed(user_id: str):
|
|
224
|
+
"""Aggregate popular movies with user favorites and watchlist"""
|
|
225
|
+
# Fetch from multiple services in parallel
|
|
226
|
+
popular_movies = await tmdb.get_popular_movies()
|
|
227
|
+
favorites = await users.get_favorites(user_id)
|
|
228
|
+
watchlist = await users.get_watchlist(user_id)
|
|
229
|
+
|
|
230
|
+
# Enrich movie data with user context
|
|
231
|
+
for movie in popular_movies:
|
|
232
|
+
movie["is_favorite"] = movie["id"] in favorites
|
|
233
|
+
movie["is_in_watchlist"] = movie["id"] in watchlist
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
"movies": popular_movies,
|
|
237
|
+
"favorites_count": len(favorites),
|
|
238
|
+
"watchlist_count": len(watchlist)
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Aggregation Example - Node.js (v2.0)
|
|
167
243
|
|
|
168
244
|
```javascript
|
|
169
245
|
const ParallelAggregator = require("./utils/aggregator");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bffgen",
|
|
3
|
-
"version": "2.1
|
|
4
|
-
"description": "Backend-for-Frontend (BFF) generator - Scaffold secure, production-ready BFF services in Go,
|
|
3
|
+
"version": "2.2.1",
|
|
4
|
+
"description": "Backend-for-Frontend (BFF) generator - Scaffold secure, production-ready BFF services in Go, Node.js, or Python",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"bffgen": "bin/bffgen.js"
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"express",
|
|
21
21
|
"expressjs",
|
|
22
22
|
"fastify",
|
|
23
|
+
"fastapi",
|
|
24
|
+
"python",
|
|
23
25
|
"go",
|
|
24
26
|
"golang",
|
|
25
27
|
"microservices",
|