Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/romch007/adonis-pubsub
PubSub provider for AdonisJS
https://github.com/romch007/adonis-pubsub
adonisjs google-pubsub mqtt pubsub redis typescript
Last synced: 1 day ago
JSON representation
PubSub provider for AdonisJS
- Host: GitHub
- URL: https://github.com/romch007/adonis-pubsub
- Owner: romch007
- License: mit
- Created: 2022-06-26T10:20:49.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-02T10:19:03.000Z (over 1 year ago)
- Last Synced: 2024-10-30T00:44:19.979Z (15 days ago)
- Topics: adonisjs, google-pubsub, mqtt, pubsub, redis, typescript
- Language: TypeScript
- Homepage:
- Size: 2.61 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# adonis-pubsub
> PubSub provider for AdonisJS[![npm-image]][npm-url] [![license-image]][license-url] [![typescript-image]][typescript-url]
PubSub provider for AdonisJS
Supported brokers:
- MQTT
- Google PubSub
- Redis## Installation
```
npm install --save adonis-pubsub
```
Configuration:
```
node ace configure adonis-pubsub
```
## Per driver configuration
- ### MQTT configuration
```
npm install --save async-mqtt
```
- ### Google PubSub configuration
```
npm install --save @google-cloud/pubsub
```
- ### Redis configurationPlease configure `@adonisjs/redis` ([docs](https://docs.adonisjs.com/guides/redis)) package and set the appropriate redis connection name in `config/pubsub.ts`
## Usage
```ts
import Event from '@ioc:Adonis/Core/Event'
import Logger from '@ioc:Adonis/Core/Logger'
import PubSub from '@ioc:Romch007/PubSub'// Subscribe to topic and listen for message
PubSub.subscribe('example')
Event.on('pubsub:message', ({ topic, message }) => {
Logger.info(`Message from ${topic}: ${message.toString()}`)
})// Publish message to topic
await PubSub.publish('example', Buffer.from('message data'))
```[github-actions-image]: https://github.com/adonis-pubsub/actions/workflows/test.yml
[github-actions-url]: https://img.shields.io/github/workflow/status/adonis-pubsub/test?style=for-the-badge "github-actions"[npm-image]: https://img.shields.io/npm/v/adonis-pubsub.svg?style=for-the-badge&logo=npm
[npm-url]: https://npmjs.org/package/adonis-pubsub "npm"[license-image]: https://img.shields.io/npm/l/adonis-pubsub?color=blueviolet&style=for-the-badge
[license-url]: LICENSE.md "license"[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[typescript-url]: "typescript"