# cunic

> rabbitmq api wrapper

Latest version **0.1.2** (published 2019-12-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install cunic
pnpm add cunic
yarn add cunic
bun add cunic
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2019-12-07 |
| First published | 2019-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 99.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | kugtong33 |
| Keywords | rabbitmq, amqp, wrapper |

## Links

- npm: https://www.npmjs.com/package/cunic
- Repository: https://github.com/kugtong33/cunic
- Homepage: https://github.com/kugtong33/cunic#readme
- Issues: https://github.com/kugtong33/cunic/issues
- npm.io page: https://npm.io/package/cunic

## Dependencies (4)

- [uuid](https://npm.io/package/uuid.md) ^3.3.3
- [ramda](https://npm.io/package/ramda.md) ^0.26.1
- [amqplib](https://npm.io/package/amqplib.md) ^0.5.5
- [highoutput-utilities](https://npm.io/package/highoutput-utilities.md) 0.0.10

## Recent versions

- 0.1.2 (latest) — 2019-12-07
- 0.1.1 — 2019-10-16

## README

# Cunic

This is a simple rabbitmq wrapper with specific messaging patterns, **pubsub** and **rpc**.

```shell
npm install cunic
```

## Getting Started

```typescript
import Cunic from 'cunic';

const cunic = new Cunic();

cunic.connect().then(async () => {
  const pubsub = await cunic.createPubSub();

  /* subscribe to an amqp exchange */
  await pubsub.subscribe('api.account.create', (message) => { console.log(`pubsub: received ${message}`); });


  /* publish to an amqp exchange */
  await pubsub.publish('api.account.create', () => ({ message: 'ping' }));
});
```

The API is simple, this is an ongoing experiment, and usage is simple as well.

## API

#### Cunic()

The constructor accepts a single parameter, `hostname`. Default value is `amqp://localhost`.

#### Cunic.connect()

Initializes the connection and channel.

#### Cunic.disconnect()

Closes the connection and channel.

### PubSub

Amqp wrapper for the Pub/Sub pattern.

#### PubSub.subscribe()

Subscribe to an exchange using the string input as exchange name.

#### PubSub.publish()

Publish to the exchange using the string input as exchange name, all subscribers will receive the message.

### RPC

Amqp wrapper for the RPC pattern.

#### RPC.serve()

RPC Queue server using the string input as queue name. Each queue server has its dedicated queue.

#### RPC.call()

Calls a remote procedure using the string input as queue name.

---
_Source: https://npm.io/package/cunic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
