@tomassabol/event-bus
v1.0.0
Published
EventBridge Bus
Readme
Event Bus
Deployment
Deploy application stack:
./scripts/cdk.sh deploy app --profile <aws-profile> --stage <stage>Deploy CodePipeline stack for automatic deployments:
./scripts/cdk.sh deploy app-pipeline --profile <aws-profile> --stage <stage>Use in other systems
Event bus
To be able to use the event bus, you need to add it your stack:
import * as events from "aws-cdk-lib/aws-events"
import { Construct } from "constructs"
export class EventBus extends Construct {
constructor(scope: IBaseConstruct, id: string) {
super(scope, id)
events.EventBus.fromEventBusName(this, "EventBus", "event-bus-name")
}
}Event types
You can also use the package as a library to share the types of events that are either being sent to the bus or consumed from that bus by different systems.
Install the package:
npm install @gymbeam/event-busand then use it in your code:
import { BUS_EVENT_TYPES, PickingCompletedEvent } from "@gymbeam/event-bus"
...
const event: PickingCompletedEvent = {
refId: "1",
refType: "ORDER",
orderRef: "123",
boxId: "1",
pickerId: 123,
isMultilevel: false,
isPaperless: true,
totalWeight: 123,
pickedWeight: 123,
}
await sendEvent({
eventBusName,
eventType: BUS_EVENT_TYPES.PICKING_COMPLETED,
event,
})
sendEvent()is a method that would use@aws-sdk/client-eventbridgeto send events to the bus.
Event Map

