Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rafaelgss/fastify-amqp
Plugin with interface to AMQP protocol - RabbitMQ
https://github.com/rafaelgss/fastify-amqp
fastify fastify-amqp fastify-plugin fastify-rabbitmq hacktoberfest
Last synced: 12 days ago
JSON representation
Plugin with interface to AMQP protocol - RabbitMQ
- Host: GitHub
- URL: https://github.com/rafaelgss/fastify-amqp
- Owner: RafaelGSS
- License: mit
- Created: 2019-06-21T17:00:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-17T03:54:25.000Z (about 1 year ago)
- Last Synced: 2024-11-01T12:52:02.506Z (19 days ago)
- Topics: fastify, fastify-amqp, fastify-plugin, fastify-rabbitmq, hacktoberfest
- Language: JavaScript
- Homepage:
- Size: 61.5 KB
- Stars: 23
- Watchers: 2
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastify-amqp
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
![CI workflow](https://github.com/RafaelGSS/fastify-amqp/workflows/CI%20workflow/badge.svg?branch=master)Fastify AMQP connection plugin wrapper to amqplib, to use with RabbitMQ
## Installation
This is a [Node.js](https://nodejs.org/) module available through the
[npm registry](https://www.npmjs.com/). It can be installed using the
[`npm`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally)
or
[`yarn`](https://yarnpkg.com/en/)
command line tools.```sh
npm install fastify-amqp --save
```## Tests
```sh
npm install
npm test
```## Usage
```js
const fastify = require('fastify')()fastify.register(require('fastify-amqp'), {
// the default value is amqp
protocol: 'amqp',
hostname: 'localhost',
// the default value is 5672
port: 5672,
// the default value is guest
username: 'guest',
// the default value is guest
password: 'guest'
// the default value is empty
vhost: ''
})fastify.get('/', function (request, reply) {
const channel = this.amqp.channelconst queue = 'hello'
const msg = 'Hello world'channel.assertQueue(queue, {
durable: false
})
channel.sendToQueue(queue, Buffer.from(msg))
reply.send(' [x] Sent ' + msg)
})fastify.listen(3000, err => {
if (err) throw err
})
```## Reference
This plugin is just a wrapper to [amqplib](https://github.com/squaremo/amqp.node).
Contains:
- `amqp.connection` API to [here](http://www.squaremobius.net/amqp.node/channel_api.html#api_reference)
- `amqp.channel` API to [here](http://www.squaremobius.net/amqp.node/channel_api.html#channel)## Dependencies
- [amqplib](https://ghub.io/amqplib): An AMQP 0-9-1 (e.g., RabbitMQ) library and client.
- [fastify-plugin](https://ghub.io/fastify-plugin): Plugin helper for Fastify## Dev Dependencies
- [fastify](https://ghub.io/fastify): Fast and low overhead web framework, for Node.js
- [pre-commit](https://ghub.io/pre-commit): Automatically install pre-commit hooks for your npm modules.
- [standard](https://ghub.io/standard): JavaScript Standard Style
- [tap](https://ghub.io/tap): A Test-Anything-Protocol library for JavaScript
- [typescript](https://ghub.io/typescript): TypeScript is a language for application scale JavaScript development## License
MIT