@motech-development/messages
v1.0.6
Published
Normalise broker messages
Downloads
15
Readme
@motech-development/messages
Normalise broker messages
Constructs a consistent broker message.
Installation
Add @motech-development/messages
as a dependency.
# Yarn
yarn add @motech-development/messages
# NPM
npm i @motech-development/messages
Usage
Use the message
utility to create a new message.
import { message } from '@motech-development/messages';
const dataMsg = message({
data: {
anything: 'can',
go: 'in here',
},
});
const idMsg = message({
id: 'your-id-goes-here',
});
const dataWithIdMsg = message({
data: {
anything: 'can',
go: 'in here',
},
id: 'your-id-goes-here',
});
client.send('create', dataMsg);
client.send('remove', idMsg);
client.send('update', msg);