Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
const event = {
domain: User,
eventName: UserCreatedSuccess,
eventData: {
username: 'newUserName',
email: '',
originalImageUrl: 'some url',
const { schemas, supportedEvents
} = await loadRegistry();
// Step 1: check if event domain is defined and event is defined in it
const supportedEventStatus = supportedEvents[event.domain
if (supportedEventStatus === undefined) {
// oops, event is not defined. Throw error
throw new Error('event is not defined in the registry');
// if you sent the schema over the wire using describe, recreate a joi object
const joiSchema =[event.domain
const { error
} = joiSchema.validate(event);
if (error === undefined) {
// event is valid, raise the event
} else {
// event is invalid. raise error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment