File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,29 @@ const job = new OutboxPeriodicJob(
3535
3636Job will take care of processing outbox entries emitted by:
3737``` typescript
38- const emitter = new OutboxEventEmitter (
38+ import {
39+ type CommonEventDefinition ,
40+ enrichMessageSchemaWithBase ,
41+ } from ' @message-queue-toolkit/schemas'
42+
43+ const MyEvents = {
44+ created: {
45+ ... enrichMessageSchemaWithBase (
46+ ' entity.created' ,
47+ z .object ({
48+ message: z .string (),
49+ }),
50+ ),
51+ },
52+ } as const satisfies Record <string , CommonEventDefinition >
53+
54+ type MySupportedEvents = (typeof TestEvents )[keyof typeof TestEvents ][]
55+
56+ const emitter = new OutboxEventEmitter <MySupportedEvents >(
3957 // Same instance of outbox storage that is used by OutboxPeriodicJob
4058 outboxStorage
4159)
60+
61+ // It pushes the entry to the storage, later will be picked up by the OutboxPeriodicJob
62+ await emitter .emit (/* args */ )
4263```
You can’t perform that action at this time.
0 commit comments