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

node-sms-sdk

v0.0.4

Published

Sdk for working with multiple sms gateway.

Downloads

8

Readme

node-sms-sdk

Sdk for working with multiple sms gateway.

Install

    npm i --save node-sms-sdk

or

    yarn add node-sms-sdk

then you use in your project

    const nodeSmsSdk = require('node-sms-sdk')

Api

    /**
    * @param sdk : The name of the sdk. This could be anything, except
    *              when using an internally shipped sdk like 'twilio' or 'infobip'.
    *              You can override any of the internally shipped ones with yours by calling this
    *              method and passing an adapter
    * @param config : (object) the configuration needed by this sdk
    * @param adapter : (module) the sdk's adapter. This is used when using an external sdk
    **/
    nodeSmsSdk.addConfig(sdk: string, config:object [, adapter]) : void

	/**
    * @param sdk : the name of the sdk
    * 
    * @return : returns the config for that sdk, if not available, it
    *           returns all available config
    **/
    nodeSmsSdk.getConfig(sdk: string) : Object
    
    /**
    * @param sdk : the name of the sdk that you want to set as the
    *              default
    **/
    nodeSmsSdk.use(sdk: string) : void
    
    /**
    * @param sdk : the name of the sdk that you want to get
    * @return : returns the instance of the raw sdk.
    **/
    nodeSmsSdk.getSdkInstance(sdk: string) : sdk
    
    /**
    * @param data : (object)
    * data = {
    * 	from: 'sender',
    * 	to: 'recipient', //this could be an array
    * 	body: 'message to be sent'
	* }
    * @return : Promise
    **/
    nodeSmsSdk.send(data: object) : Promise<any>

Build your own adapter

Building your own adapter is pretty easy and straight forward. Simply write a module that has the following exports. What to do when you're done??

  1. Publish to npm and have others used it.
  2. Fork this repo
  3. Add your sdk to the list of available sdk below, add link to your repo so others can find, send a PR
	module.exports = {
    	/**
        * This takes a config object that it can use to initialize 
        * module
        **/
    	loadConfig: (config: object) => {
        	
        },
        
        /**
        * Returns a tbe current instance of the adapter. 
        * Gives you access to the raw module by the provider
        * 
        * @return adapter
        **/
        raw: () => {
        	
        },
        
        /**
        * This method should send a message and return a promise
        * 
        * @param from: number or name sending the message
        * @parm to: the number(s) you're sending the message to. 
        *           This could also be an array
        * @parm body: The message to be sent
        **/
        send: ({ from, to, body }) => {
        	
        }
    }

SDKs available

  1. twilio (internal)
  2. infobip (internal)
  3. ADD_YOURS_HERE (send PR)

Example usage

    //require  module 
	const nodeSmsSdk = require('node-sms-sdk')

    //add config for an sdk. twilio ships internally
    nodeSmsSdk.addConfig('twilio',{
        accountSid: 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 
        authToken: 'your_auth_token'
    })

    //use twilio as default
    nodeSmsSdk.use('twilio')

    //send message
    nodeSmsSdk.send({
    	from: '+2348120725879', 
        to: '+23408040320343', 
        body: 'This works yay!!!'
    }).then(console.log).catch(console.log)