@crossdelta/platform-sdk 0.3.23 → 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 +27 -4
- 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
|
@@ -158,21 +158,42 @@ my-platform/
|
|
|
158
158
|
|
|
159
159
|
## ⚡ Event-Driven Architecture
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
Every workspace includes **NATS + JetStream** for event-driven microservices communication using **[`@crossdelta/cloudevents`](https://github.com/orderboss/platform/tree/main/packages/cloudevents)**:
|
|
162
162
|
|
|
163
163
|
- 🎯 **Type-safe event handlers** with Zod schemas
|
|
164
164
|
- 🔄 **Auto-discovery** of event handlers (`*.event.ts` files)
|
|
165
165
|
- 📦 **Publisher/Consumer patterns** out of the box
|
|
166
|
-
- 🚀 **
|
|
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
|
|
167
188
|
|
|
168
|
-
**Publish events:**
|
|
169
189
|
```typescript
|
|
170
190
|
import { publish } from '@crossdelta/cloudevents'
|
|
171
191
|
|
|
172
192
|
await publish('orders.created', { orderId: 'ord_123', total: 99.99 })
|
|
173
193
|
```
|
|
174
194
|
|
|
175
|
-
|
|
195
|
+
### Consume Events (Auto-Discovered)
|
|
196
|
+
|
|
176
197
|
```typescript
|
|
177
198
|
// services/notifications/src/handlers/order-created.event.ts
|
|
178
199
|
import { handleEvent } from '@crossdelta/cloudevents'
|
|
@@ -189,6 +210,8 @@ export default handleEvent(OrderCreatedSchema, async (data) => {
|
|
|
189
210
|
})
|
|
190
211
|
```
|
|
191
212
|
|
|
213
|
+
**📚 Learn more:** See `services/nats/README.md` in your workspace for monitoring, configuration, and JetStream details.
|
|
214
|
+
|
|
192
215
|
<br />
|
|
193
216
|
|
|
194
217
|
---
|