npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

notification-hub-js-sdk

v1.1.2

Published

TypeScript SDK to communicate with Aasaanjobs Notification Hub and send notifications to users.

Downloads

4

Readme

Typescript Aasaanjobs NotificationHub Client

Typescript SDK to communicate with Aasaanjobs Notification Hub and send notifications to users.

Supported Notification Channels

  • Short Messaging Service (SMS)
  • Email
  • WhatsApp
  • Mobile Push (FCM)

Installation

npm install <package-name>

Local Testing

Export environment variable as shown in the sample notification below. And run -

npm run test

Publishing

Log in to npm account on local using -

npm login

To publish a beta version for dev testing or QA -

Update the version in package.json to <version>-beta.<number>. And run -

npm publish --tag beta

To publish a release version, update version in package.json to actual release version and run -

npm publish

Usage

Each notification is referred to as Task in this library. A single Task can contain multiple channels, i.e., a single Task can contain both Email and WhatsApp notification data. This Task is then validated via Protocol Buffers and pushed to corresponding Notification Hub Amazon SQS queue.

SQS Options Interface - It needs to be configured with appropriate options for the type of notification to be sent.

interface ISQSOptions {
    queueUrl?: string
    marketingQueueUrl?: string
    otpQueueUrl?: string
    accessKeyId: string
    secretAccessKey: string
    region?: string
}

Task Interface - To add notification task for each channel.

interface ITasks {
    email?: EmailTask
    sms?: SMSTask
    whatsapp?: WhatsAppTask
    push?: PushTask
}

Task Constructor - Available options to initialize the Task object.

constructor(
    sqsOptions: ISQSOptions,
    name: string,
    sentById: string,
    client: string,
    platform: NotificationTask.Platform,
    messageType: NotificationTask.MessageType,
    tasks: ITasks,
    waterfallType?: NotificationTask.WaterfallMode
)

Sample Notification Task to send an SMS:

import { uuid } from 'uuidv4'
import { Task, ISQSOptions, ITasks, SMSTask, Platform, MessageType, WaterfallMode, Waterfall } from 'notification-hub-js-sdk'

let template = "https://static.aasaanjobs.com/sms_template.html"
let mobile = "1234567890"
let userId = uuid().toString()
let waterfall = new Waterfall()
waterfall.setPriority(1)
waterfall.setOffsettime(60)
let sms = new SMSTask(template, mobile, userId, waterfall)

let sqsOptions: ISQSOptions = {
    queueUrl: process.env.QUEUE_URL || "",
    marketingQueueUrl: process.env.MARKETING_QUEUE_URL || "",
    otpQueueUrl: process.env.OTP_QUEUE_URL || "",
    accessKeyId: process.env.SQS_ACCESS_KEY || "",
    secretAccessKey: process.env.SQS_SECRET_KEY || "",
    region: process.env.SQS_REGION
}

let name = "Test SMS"
let sentById = uuid().toString()
let client = "JS SDK Test Client"
let platform = Platform.OLXPEOPLE
let messageType = MessageType.MARKETING
let waterfallType = WaterfallMode.AUTO

let tasks: ITasks = {
    sms: getSMSTask()
}

let task = new Task(sqsOptions, name, sentById, client, platform, messageType, tasks, waterfallType)
task.send()

Requirements

Each application which uses this library must configure Amazon SQS configurations to successfully send notification task to Hub.

interface ISQSOptions {
    queueUrl?: string
    marketingQueueUrl?: string
    otpQueueUrl?: string
    accessKeyId: string
    secretAccessKey: string
    region?: string
}

For Transactional notifications queueUrl should be provided.

For Marketing notifications marketingQueueUrl should be provided.

For OTP notifications otpQueueUrl should be provided.

SQS options accessKeyId, secretAccessKey, region are required.