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

katar-sms

v0.0.1

Published

SMS queue system can be used to send and receive sms messages from a phone application

Downloads

2

Readme

Katar SMS

Queue server for sending and receiving SMS.

The library does not do any analysis around whether an SMS is in response to a previous SMS, it simply emits an event when an SMS is received.

Usage

var katarSms = require('./katar-sms');
var smsQueue = katarSms();

// send a new sms
co(function *() {
	return yield smsQueue.send({
		to: '+61404341143',
		msg: 'this is an sms'
	});
})(function(err, id) {
	console.log('sms id: %s', id);
});

// listen for sms sent event
smsQueue.on('sent', function(sms) {
	console.log('Id - %s, To - %s, Msg - %s', sms._id, sms.to, sms.msg);
});

Since sms queue extends a katar queue instance, all of the original events are still emitted on the smsQueue.

// emitted if sending the sms failed
smsQueue.on('failed', function(task) {
	var sms = task.data;
	console.log('%s: failed to send msg to %s', sms._id, sms.to);
});

// emitted if an sms is sent
smsQueue.on('done', function(task) {
	var sms = task.data;
	console.log('%s: sent msg to %s', sms._id, sms.to);
});

Incoming SMS

The sms queue also provides a mechanism for clients to notify the sms queue when an incoming sms is received.

// add an event handler for processing received sms
smsQueue.on('sms', function(sms) {
	console.log('%s sent msg: %s', sms.from, sms.msg);
});

Clients

Clients can be implemented in any language or platform as long as they implement the HTTP API. The HTTP API for SMS queue is the same as a katar HTTP worker. The only addition to the HTTP worker API is a /receive route appended to the queue path.

Consider the following sms queue:

var katar = require('katar')();
var queue = katar.queue('sms');
var katarSms = require('katar-sms');
var smsQueue = katarSms({
	katar: katar,
	queue: queue,
	port: 3000,
	ip: '127.0.0.1'
});

Poll for queued SMS to be sent

A sample request is shown below. See Poll for next queued task for more details.

Request:

POST /v1/queue/sms

{}

Response:

{
	tasks: [{ _id: 1, data: { to: '0404123456', msg: 'msg to be sent' }]
}

Mark SMS as sent

A sample request is shown below. See Mark task/tasks as done for more details.

Request:

POST /v1/queue/sms

{
	tasks: [
		{ _id: 'abc', status: 'done' },
		{ _id: 'def', status: 'failed', error: 'some error' }
	]
}

Response:

See Mark task/tasks as done.

Received SMS

To notify the server of SMS received by the worker agent, send a POST request to /v1/queue/:queue/receive.

Request:

POST /v1/queue/sms/receive

{
	sms: { from: '0404123456', msg: 'msg received' }
}

Response:

The server sends a 204 No Content status code if there were no errors.