1.1.3 • Published 12 months ago

kiwee v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Kiwee

Kiwee Logo

Kiwee is a TypeScript library for handling message serialization, validation, and dispatching between consumers and actions based on predefined schemas.

Installation

npm install kiwee class-validator

Usage

Initialize Configuration

Create a kiwee-config.json file in your project root:

npx kiwee init

Customize the configuration file as needed.

Generate Files

Generate the necessary handler files and types based on the configuration:

npx kiwee generator

Publishing Messages

Use the Publisher class to prepare messages for publication:

import { Publisher } from 'kiwee';

const message = Publisher.prepareMessageToPublish({
  consumer: 'ConsumerName',
  action: 'ActionName',
  payload: { /* your payload */ },
});

// Publish the message using your preferred messaging system

Consuming Messages

Use the ConsumerDispatcher to dispatch incoming messages to the appropriate handlers:

import { ConsumerDispatcher } from 'kiwee';

// On message received
ConsumerDispatcher.dispatchMessage(receivedMessage);

Schema Registry

Access the schema registry to validate, serialize, or deserialize messages:

import { schemaRegistry } from 'kiwee';

schemaRegistry.validate('ConsumerName', 'ActionName', payload);

const serializedMessage = schemaRegistry.serialize({
  consumer: 'ConsumerName',
  action: 'ActionName',
  payload,
});

const deserializedMessage = schemaRegistry.deserialize(serializedMessage);

License

MIT

1.1.1

12 months ago

1.1.3

12 months ago

1.1.2

12 months ago

1.0.0

12 months ago