@crossdelta/platform-sdk 0.3.22 → 0.3.24
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 +61 -14
- package/bin/cli.js +93 -93
- package/bin/templates/workspace/infra/services/nats.ts.hbs +55 -0
- package/bin/templates/workspace/services/nats/README.md +107 -0
- package/bin/templates/workspace/services/nats/nats.conf +31 -0
- package/bin/templates/workspace/services/nats/nats.prod.conf +27 -0
- package/bin/templates/workspace/services/nats/package.json.hbs +7 -0
- package/bin/templates/workspace/services/nats/scripts/start-dev.sh.hbs +56 -0
- package/package.json +1 -1
- package/bin/templates/workspace/infra/services/example.ts.hbs +0 -21
- package/bin/templates/workspace/services/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -156,6 +156,66 @@ my-platform/
|
|
|
156
156
|
|
|
157
157
|
---
|
|
158
158
|
|
|
159
|
+
## ⚡ Event-Driven Architecture
|
|
160
|
+
|
|
161
|
+
Every workspace includes **NATS + JetStream** for event-driven microservices communication using **[`@crossdelta/cloudevents`](https://github.com/orderboss/platform/tree/main/packages/cloudevents)**:
|
|
162
|
+
|
|
163
|
+
- 🎯 **Type-safe event handlers** with Zod schemas
|
|
164
|
+
- 🔄 **Auto-discovery** of event handlers (`*.event.ts` files)
|
|
165
|
+
- 📦 **Publisher/Consumer patterns** out of the box
|
|
166
|
+
- 🚀 **NATS auto-scaffolded** in `services/nats/` with Docker setup
|
|
167
|
+
- 🗄️ **JetStream persistence** for durable event streaming
|
|
168
|
+
|
|
169
|
+
### NATS Message Broker
|
|
170
|
+
|
|
171
|
+
Every workspace includes a pre-configured NATS service:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Auto-started with `bun dev`
|
|
175
|
+
services/nats/
|
|
176
|
+
├── nats.conf # Local dev config (JetStream enabled)
|
|
177
|
+
├── nats.prod.conf # Production config (auth + persistence)
|
|
178
|
+
├── scripts/start-dev.sh # Docker startup script
|
|
179
|
+
└── README.md # Full NATS documentation
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Local Development:**
|
|
183
|
+
- Runs in Docker on ports `4222` (client) and `8222` (HTTP monitoring)
|
|
184
|
+
- Data persisted in `.nats-data/` directory
|
|
185
|
+
- Health check: `curl http://localhost:8222/healthz`
|
|
186
|
+
|
|
187
|
+
### Publish Events
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import { publish } from '@crossdelta/cloudevents'
|
|
191
|
+
|
|
192
|
+
await publish('orders.created', { orderId: 'ord_123', total: 99.99 })
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Consume Events (Auto-Discovered)
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
// services/notifications/src/handlers/order-created.event.ts
|
|
199
|
+
import { handleEvent } from '@crossdelta/cloudevents'
|
|
200
|
+
import { z } from 'zod'
|
|
201
|
+
|
|
202
|
+
const OrderCreatedSchema = z.object({
|
|
203
|
+
type: z.literal('orders.created'),
|
|
204
|
+
orderId: z.string(),
|
|
205
|
+
total: z.number(),
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
export default handleEvent(OrderCreatedSchema, async (data) => {
|
|
209
|
+
await sendNotification(data)
|
|
210
|
+
})
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**📚 Learn more:** See `services/nats/README.md` in your workspace for monitoring, configuration, and JetStream details.
|
|
214
|
+
|
|
215
|
+
<br />
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
159
219
|
## 🛠 CLI Commands
|
|
160
220
|
|
|
161
221
|
<details>
|
|
@@ -247,22 +307,9 @@ GitHub Secrets:
|
|
|
247
307
|
- Pulumi CLI
|
|
248
308
|
- Docker (for local Supabase/NATS)
|
|
249
309
|
|
|
250
|
-
<br />
|
|
251
|
-
|
|
252
|
-
---
|
|
253
|
-
|
|
254
|
-
## � Community & Support
|
|
255
|
-
|
|
256
|
-
- 📖 [Full Documentation](https://github.com/orderboss/platform/tree/main/packages/platform-sdk/docs)
|
|
257
|
-
- 🐛 [Report Issues](https://github.com/orderboss/platform/issues)
|
|
258
|
-
- 💡 [Feature Requests](https://github.com/orderboss/platform/discussions)
|
|
259
|
-
- 📦 [npm Package](https://www.npmjs.com/package/@crossdelta/platform-sdk)
|
|
260
|
-
- ⭐ [Star on GitHub](https://github.com/orderboss/platform)
|
|
261
|
-
|
|
262
|
-
<br />
|
|
263
310
|
|
|
264
311
|
---
|
|
265
312
|
|
|
266
|
-
##
|
|
313
|
+
## 📄 License
|
|
267
314
|
|
|
268
315
|
MIT © Crossdelta
|