# adonis6-amqp

> AdonisJS 6 AMQP provider

Latest version **3.0.3** (published 2023-12-20) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install adonis6-amqp
pnpm add adonis6-amqp
yarn add adonis6-amqp
bun add adonis6-amqp
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.3 |
| Published | 2023-12-20 |
| First published | 2023-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.16.0 |
| Dependencies | 2 |
| Unpacked size | 34 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | tom-brulin |
| Maintainers | tombrulin |
| Keywords | adonis, adonisjs, amqp, queue, rabbitmq |

## Links

- npm: https://www.npmjs.com/package/adonis6-amqp
- Repository: https://github.com/tom-brulin/adonis6-amqp
- Homepage: https://github.com/tom-brulin/adonis6-amqp#readme
- Issues: https://github.com/tom-brulin/adonis6-amqp/issues
- npm.io page: https://npm.io/package/adonis6-amqp

## Dependencies (2)

- [amqplib](https://npm.io/package/amqplib.md) ^0.10.3
- [@poppinss/utils](https://npm.io/package/@poppinss/utils.md) ^6.5.1

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 3.0.3 (latest) — 2023-12-20
- 3.0.2 — 2023-12-20
- 3.0.1 — 2023-12-20
- 3.0.0 — 2023-12-20
- 2.0.5 — 2023-12-19
- 2.0.4 — 2023-12-19
- 2.0.3 — 2023-12-19
- 2.0.2 — 2023-12-19
- 2.0.1 — 2023-12-19
- 2.0.0 — 2023-12-19
- 1.0.3 — 2023-11-29
- 1.0.2 — 2023-11-29
- 1.0.1 — 2023-11-29

## README

# adonis6-amqp

<br />

[![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]

## Introduction

Typesafe AMQP provider for AdonisJS 6. Feel free to contribute or give suggestions.

## Quick setup

### Install the library
```sh
npm i adonis6-amqp
```
```sh
yarn add adonis6-amqp
```
```sh
pnpm add adonis6-amqp
```

### Configure
```sh
node ace configure adonis6-amqp
```

## Setup

Once installed, you can configure Adonis6 AMQP in your application inside `config/amqp.ts`.

```typescript
const amqpConfig = defineConfig({
  connection: {
    host: env.get('AMQP_HOST'),
    port: env.get('AMQP_PORT'),
    user: env.get('AMQP_USER'),
    password: env.get('AMQP_PASSWORD'),
  }
})

declare module 'adonis6-amqp' {
  interface AmqpQueues {
    // 'your.queue': Infer<typeof yourValidator>
  }
}
```

### Create a queue

Define your queues inside `start/amqp.ts`.

```typescript
import { amqp } from 'adonis6-amqp'

export const yourQueue = await amqp
  .createQueue('your.queue', yourValidator)
  .useHandler(YourHandler) // Optional
  .register()
```

#### Validator

Each queues need a validator to validate incoming/outgoing data (you must use `vinejs` to create queue validators).

```typescript
import vine from '@vinejs/vine'

export const yourValidator = vine.compile(
  vine.object({
    randomString: vine.string(),
  })
)
```

#### Handler

If you want to listen on the queue you need to create a queue handler.

```typescript
import { AmqpQueues, QueueHandler } from 'adonis6-amqp'

export class YourHandler extends QueueHandler {
  handle(data: AmqpQueues['your.queue']) { }
  handleError(error: Error) { }
}
```

### Send message to queue

Just import the queue you registered where you want to send a message.

```typescript
import { yourQueue } from '#start/amqp'

// Typesafe
yourQueue.sendMessage({ randomString: 'test' })
```

## License

Adonis6 AMQP is open-sourced software licensed under the [MIT license](LICENSE.md).

[npm-image]: https://img.shields.io/npm/v/adonis6-amqp/latest.svg?style=for-the-badge&logo=npm
[npm-url]: https://www.npmjs.com/package/adonis6-amqp/v/latest "npm"
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[license-url]: LICENSE.md
[license-image]: https://img.shields.io/github/license/tom-brulin/adonis6-amqp?style=for-the-badge

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