bffgen 1.3.0 → 2.1.0
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 +46 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ cd my-project && npm run dev
|
|
|
46
46
|
- **Node.js Fastify** - Fast, schema-based framework
|
|
47
47
|
- **Go (Chi/Echo/Fiber)** - High-performance, compiled servers
|
|
48
48
|
|
|
49
|
-
### 🚀 **Production-Ready Aggregation
|
|
49
|
+
### 🚀 **Production-Ready Aggregation**
|
|
50
50
|
|
|
51
51
|
- **Parallel Service Calls** - Fetch from multiple backends simultaneously
|
|
52
52
|
- **Redis Caching** - Built-in caching with automatic fallback
|
|
@@ -54,6 +54,7 @@ cd my-project && npm run dev
|
|
|
54
54
|
- **Request Batching** - Avoid N+1 queries
|
|
55
55
|
- **Response Transformation** - Filter and optimize API responses
|
|
56
56
|
- **Field Selection** - GraphQL-like field filtering for REST
|
|
57
|
+
- **Go & Node.js Parity** - Same utilities available in both runtimes (v2.0+)
|
|
57
58
|
|
|
58
59
|
### 🔒 **Security Features**
|
|
59
60
|
|
|
@@ -70,6 +71,18 @@ cd my-project && npm run dev
|
|
|
70
71
|
- **Hot Reload** - Development mode with auto-restart
|
|
71
72
|
- **Comprehensive Tests** - Jest setup with sample tests
|
|
72
73
|
|
|
74
|
+
### ⚡ **v2.0 Enhancements** (NEW)
|
|
75
|
+
|
|
76
|
+
- **Idempotent Generation** - Safe to run `generate` multiple times
|
|
77
|
+
- **Config Validation** - `bffgen config validate` catches errors pre-generation
|
|
78
|
+
- **Colorized Diffs** - Preview changes with `--dry-run`
|
|
79
|
+
- **Progress Indicators** - Visual feedback during operations
|
|
80
|
+
- **Auto-Route Registration** - Routes automatically imported
|
|
81
|
+
- **Runtime Override** - `--runtime` flag for explicit control
|
|
82
|
+
- **Transaction Rollback** - Failed operations automatically rollback
|
|
83
|
+
- **Smart Tool Detection** - Auto-detects missing dependencies
|
|
84
|
+
- **Memory Safety CI** - Automated leak detection and security scanning
|
|
85
|
+
|
|
73
86
|
---
|
|
74
87
|
|
|
75
88
|
## 🛠️ Commands
|
|
@@ -87,6 +100,21 @@ bffgen add-template auth
|
|
|
87
100
|
# Generate routes, controllers, and services
|
|
88
101
|
bffgen generate
|
|
89
102
|
|
|
103
|
+
# Generate with preview (v2.0)
|
|
104
|
+
bffgen generate --dry-run
|
|
105
|
+
|
|
106
|
+
# Force regeneration (v2.0)
|
|
107
|
+
bffgen generate --force
|
|
108
|
+
|
|
109
|
+
# Validate configuration (v2.0)
|
|
110
|
+
bffgen config validate
|
|
111
|
+
|
|
112
|
+
# Convert config formats (v2.0)
|
|
113
|
+
bffgen convert --from yaml --to json
|
|
114
|
+
|
|
115
|
+
# Add infrastructure (v2.0)
|
|
116
|
+
bffgen add-infra --ci --docker --compose
|
|
117
|
+
|
|
90
118
|
# Generate API documentation
|
|
91
119
|
bffgen generate-docs
|
|
92
120
|
|
|
@@ -121,10 +149,12 @@ my-express-bff/
|
|
|
121
149
|
│ ├── controllers/ # Business logic with aggregation
|
|
122
150
|
│ ├── services/ # HTTP clients
|
|
123
151
|
│ ├── middleware/ # Auth, validation, logging
|
|
124
|
-
│ ├── utils/ # Aggregation utilities
|
|
152
|
+
│ ├── utils/ # Aggregation utilities
|
|
125
153
|
│ │ ├── aggregator.js # Parallel requests
|
|
126
154
|
│ │ ├── cache-manager.js # Redis caching
|
|
127
155
|
│ │ ├── circuit-breaker.js # Fault tolerance
|
|
156
|
+
│ │ ├── response-transformer.js # Data transformation (v2.0)
|
|
157
|
+
│ │ ├── request-batcher.js # Request batching (v2.0)
|
|
128
158
|
│ │ └── ...
|
|
129
159
|
│ └── examples/ # Working aggregation examples
|
|
130
160
|
├── tests/ # Jest tests
|
|
@@ -133,25 +163,34 @@ my-express-bff/
|
|
|
133
163
|
└── bffgen.config.json # BFF configuration
|
|
134
164
|
```
|
|
135
165
|
|
|
136
|
-
### Aggregation Example (
|
|
166
|
+
### Aggregation Example (v2.0)
|
|
137
167
|
|
|
138
168
|
```javascript
|
|
139
169
|
const ParallelAggregator = require("./utils/aggregator");
|
|
140
170
|
const CacheManager = require("./utils/cache-manager");
|
|
171
|
+
const CircuitBreaker = require("./utils/circuit-breaker");
|
|
172
|
+
const ResponseTransformer = require("./utils/response-transformer");
|
|
141
173
|
|
|
142
174
|
const aggregator = new ParallelAggregator({ timeout: 5000 });
|
|
143
175
|
const cache = new CacheManager({ ttl: 300 });
|
|
176
|
+
const breaker = new CircuitBreaker({ failureThreshold: 5 });
|
|
177
|
+
const transformer = new ResponseTransformer();
|
|
144
178
|
|
|
145
|
-
// Fetch from multiple services in parallel
|
|
179
|
+
// Fetch from multiple services in parallel with circuit breaker
|
|
146
180
|
const results = await aggregator.fetchParallel([
|
|
147
|
-
{
|
|
181
|
+
{
|
|
182
|
+
name: "user",
|
|
183
|
+
fetch: () => breaker.execute(() => UserService.getProfile(userId)),
|
|
184
|
+
},
|
|
148
185
|
{ name: "orders", fetch: () => OrdersService.getOrders(userId) },
|
|
149
186
|
{ name: "preferences", fetch: () => PreferencesService.get(userId) },
|
|
150
187
|
]);
|
|
151
188
|
|
|
152
|
-
//
|
|
189
|
+
// Transform and sanitize responses
|
|
153
190
|
const dashboard = {
|
|
154
|
-
user:
|
|
191
|
+
user: transformer.sanitize(
|
|
192
|
+
results.find((r) => r.service === "user" && r.success)?.data
|
|
193
|
+
),
|
|
155
194
|
orders: results.find((r) => r.service === "orders" && r.success)?.data || [],
|
|
156
195
|
preferences:
|
|
157
196
|
results.find((r) => r.service === "preferences" && r.success)?.data || {},
|