Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mahmed8003/fastify-nats
Plugin for sharing nats connection across Fastify
https://github.com/mahmed8003/fastify-nats
broker fastify messaging nats pubsub rpc
Last synced: 3 months ago
JSON representation
Plugin for sharing nats connection across Fastify
- Host: GitHub
- URL: https://github.com/mahmed8003/fastify-nats
- Owner: Techie-Qabila
- License: mit
- Created: 2017-09-19T06:42:07.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-06T18:50:18.000Z (almost 6 years ago)
- Last Synced: 2024-04-12T16:33:57.428Z (7 months ago)
- Topics: broker, fastify, messaging, nats, pubsub, rpc
- Language: JavaScript
- Homepage:
- Size: 62.5 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-fastify - `fastify-nats`
README
# fastify-nats
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
[![npm version](https://img.shields.io/npm/v/fastify-nats.svg?style=flat-square)](https://www.npmjs.com/package/fastify-nats)
[![npm downloads](https://img.shields.io/npm/dm/fastify-nats.svg?style=flat-square)](https://www.npmjs.com/package/fastify-nats)[NATS](http://nats.io) Server is a simple, high performance open source messaging system for cloud native applications, IoT messaging, and microservices architectures.
Under the hood [NATS](https://github.com/nats-io/node-nats) client is used, the options that you pass to `register` will be passed to the nats client.
## Install
```
npm i fastify-nats --save
```
## Usage
Add it to you project with `register` and you are done!
You can access the *nats Connection* via `fastify.nats`.
```js
const fastify = require('fastify')fastify.register(require('fastify-nats'), {
url: 'nats:demo.nats.io:4222'
}, err => {
if (err) throw err
})fastify.listen(3000, err => {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})
```and later
```js
fastify.nats.publish(topic, message);
```## License
Licensed under [MIT](./LICENSE).