@terrajs/mono-push

0.3.2 • Public • Published

Mono Push

MonoPush module for Mono

npm version Travis Coverage license

Installation

npm install --save @terrajs/mono-push

Then, in your configuration file of your Mono application (example: conf/application.js):

module.exports = {
  mono: {
    modules: [
      '@terrajs/mono-mongodb',
      '@terrajs/mono-push'
    ]
  }
}

mono-push requires mono-mongodb, so it must be installed and declared before mono-push because modules are loaded synchronously

Configuration

mono-push will use the push property of your configuration (example: conf/development.js):

module.exports = {
  mono: {
    push: {
      io: true
    }
  }
}

When using io: true, mono-push requires mono-io, so it must be installed and declared (example: conf/application.js):

module.exports = {
  mono: {
    modules: [
      '@terrajs/mono-mongodb',
      '@terrajs/mono-io',
      '@terrajs/mono-push'
    ]
  }
}

Usage

In your modules files, you can access send helper like this:

send(event: string, query: object = {}, payload: object = {})

Example:

const { send } = require('@terrajs/mono-push')

await send('new-push', { userId: '...' }, { message: 'Welcome!' })

With conf io: true, mono-push will emit an event to every socket connected that matches the query

Readme

Keywords

Package Sidebar

Install

npm i @terrajs/mono-push

Weekly Downloads

1

Version

0.3.2

License

MIT

Last publish

Collaborators

  • gaetansenn
  • alexchopin
  • benjamincanac
  • atinux