1.0.31 • Published 3 years ago

nandanjscommunicator v1.0.31

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

jsCommunicator

Communicator client for javascript

Install

npm install jscommunicator --save

Usage

For web app

const express = require('express')
const jsComm = require('jscommunicator')
const app = express()

const config = {
                  communicator: {
                    communicatorQueueUri: 'beanstalk://localhost/dev-',
                    signingKey: 'xxxx'
                  }
                }

app.use(function (req, res, next) {
  client = new jsComm.CommunicatorClient(req, config, "accounts")
  const obj = client.getInstance('smsGenericPromotional')
  console.log(obj.getDomain())
  next()
})

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(3000, () => console.log('Example app listening on port 3000!'))

For workers

client = new jsComm.CommunicatorClient(null, config, "accounts")
const obj = client.getInstance('smsGenericPromotional')
obj.setDomain("domain value")

host eg. abc-access123.practodev.com

config eg. { communicator: { communicatorQueueUri: 'beanstalk://localhost/dev-', signingKey: 'xxxx' } }

appName eg. accounts

Get instance for the type of mail or sms

obj = client.getInstance('smsGenericPromotional')

Sending sms/email

obj.sendSms(params)
obj.sendMail(params)

Fetching sms/email info GET request

obj.getMessagesByReferenceId(2, '["FIT_RAY_SHARE_SMS"]', (err, response)=>{
  if(err){
    console.log(err);
  }
  else{
    console.log(response)}
  })

To contribute in jsCommunicator

Clone the repo

Finally build using npm run build

Update package in npm using npm publish

Notes

  • Make sure to run build before publish because it will publish the local lib folder.
  • Please don't push the lib version in git repository. Only the source code.