Skip to content

opzkit/nodeamqp

Repository files navigation

nodeamqp

Nodeamqp provides an opinionated way of using RabbitMQ for event-driven architectures.

Getting Started

Add the dependency

yarn add @opzkit/nodeamqp

Usage

See the 'examples' subdirectory.

Contributing

TODO

References

License

MIT - see LICENSE for more details.

Developing

TODO

Tests

yarn run test

Example message logger

An example message logger which dumps messages to console.

const StdOutMessageLogger = (
  content: Buffer,
  routingKey: string,
  outgoing: boolean
) => {
  let out: string = content.toString("utf-8");
  try {
    out = JSON.stringify(JSON.parse(out), null, 2);
  } catch (e) {
    // Ignore errors since out is already set
  }
  if (outgoing) {
    console.log(
      `Sending using routingkey: '${routingKey}' with content:\n${out}\n`
    );
  } else {
    console.log(
      `Received from routingkey '${routingKey}' with content:\n${out}\n`
    );
  }
};