@crossdelta/platform-sdk 0.3.37 → 0.3.39
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 +13 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -156,7 +156,7 @@ my-platform/
|
|
|
156
156
|
|
|
157
157
|
## ⚡ Event-Driven Architecture
|
|
158
158
|
|
|
159
|
-
Every workspace includes **NATS + JetStream** for event-driven microservices communication using **[`@crossdelta/cloudevents`](https://
|
|
159
|
+
Every workspace includes **NATS + JetStream** for event-driven microservices communication using **[`@crossdelta/cloudevents`](https://www.npmjs.com/package/@crossdelta/cloudevents)**:
|
|
160
160
|
|
|
161
161
|
- 🎯 **Type-safe event handlers** with Zod schemas
|
|
162
162
|
- 🔄 **Auto-discovery** of event handlers (`*.event.ts` files)
|
|
@@ -198,14 +198,22 @@ import { handleEvent } from '@crossdelta/cloudevents'
|
|
|
198
198
|
import { z } from 'zod'
|
|
199
199
|
|
|
200
200
|
const OrderCreatedSchema = z.object({
|
|
201
|
-
type: z.literal('orders.created'),
|
|
202
201
|
orderId: z.string(),
|
|
203
202
|
total: z.number(),
|
|
204
203
|
})
|
|
205
204
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
// Export type for use in use-cases
|
|
206
|
+
export type OrderCreatedEvent = z.infer<typeof OrderCreatedSchema>
|
|
207
|
+
|
|
208
|
+
export default handleEvent(
|
|
209
|
+
{
|
|
210
|
+
schema: OrderCreatedSchema,
|
|
211
|
+
type: 'orders.created',
|
|
212
|
+
},
|
|
213
|
+
async (data) => {
|
|
214
|
+
await sendNotification(data)
|
|
215
|
+
},
|
|
216
|
+
)
|
|
209
217
|
```
|
|
210
218
|
|
|
211
219
|
**📚 Learn more:** See `services/nats/README.md` in your workspace for monitoring, configuration, and JetStream details.
|