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 🙏

© 2026 – Pkg Stats / Ryan Hefner

rxws-socketio

v0.1.0

Published

A RESTful reactive websocket implementation on top of socket.io

Downloads

2

Readme

RxWS SocketIO

Reactive Web Sockets on top of SocketIO

Status: Build Status codecov.io

RxWS is a RESTful reactive JavaScript implementation on top of web sockets. This includes, GET, POST, PUT, REMOVE (DELETE), PATCH, and HEAD. RxWS guarantees message delivery by generating a correlation id for each message (to and from the server). Both the server and client automatically send an acknowledgement response for each request. If there is no acknowledgement after a timeout, an error is thrown.

RxWS implements a RESTful protocol. You can use any web socket server as long as it implements the same protocol.

Client library

The client library is available at https://github.com/CanopyTax/rxws

Setup

npm install --save rxws-socketio socket.io

Example

// Server
import io from 'socket.io';
import rxws from 'rxws-socketio';

let server = io(3000);

function rxHandler(rxSocket) {
	rxSocket.get('questions')
		.subscribe(({req, res, next}) => {
			res.send([
				{
					id: 1,
					name: 'userName',
					label: 'What is your name?'
				}
			])
		});
}

server.on('connection', function(socket) {
	rxHandler(rxws(socket));
});
// Client
import rxws from 'rxws';
import SocketIOBackend from 'rxws-socketio/lib/SocketIOBackend';

rxws.setBackend({
	backend: SocketIOBackend.default,
	url: 'http://localhost:3000'
});

setInterval(function() {
	rxws.get('questions')
		.subscribe(function(resp) {
			console.log(resp.questions);
		});
}, 1000);

API

/**
 * Middleware handler - The middleware is executed in the order that it is defined.
 *
 * @param {object} options An options object passed to the middleware
 * @return {Observable} An obserable with the request and response object which may
 *                be manipulated.
 */
rxSocket.use(options)
	.subscribe(({req, res, next}) => {
		req.requestTime = Date.now();
		next();
	});

/**
 * Error middleware handler
 *
 * @param {object} options An options object. Unused at the moment.
 * @return {Observable} Observable is passed an object with an error object, the
 *                 request, response, and next method. Calling next will route
 *                 to the next error handling middleware.
 */
rxSocket.useError(options)
	.subscribe(({err, req, res, next}) => {
		console.error(err.stack);
		res.status(500).send('Something broke!');
	});

/**
 * RESTful methods are available on rxSocket
 *
 * @param {string} Resource a dot separated path to the resource being requested.
 *                 The only available parameters for a given resource are parameters
 *                 that match a given resource. For example, the resource 'questions'
 *                 can only take a 'questions' parameter. Anything else will error.
 *                 Nested resources need to have each resource represented with a
 *                 parameter except for the last resource, which is optional.
 * @return {Observable} The observable can only be passed a single value, that value
 *                 must be destructured to get both the request and response.
 */
rxSocket.get('questions')
	.subscribe(({req, res, next}) => {
		/** Req API **/
		req.headers
		req.resource
		req.method
		req.parameters
		req.query
		req.body

		/** Res API **/
		res.headers
		res.body
		res.statusCode = 404;
		res.setHeader('name', 'value');
		res.getHeader('name');
		res.removeHeader('name');
		res.send({data: ""});

		res.status(500).send('Something broke!');
	})

/** RestFul Listeners **/
rxSocket.put('questions').subscribe(({req, res, next}) => {});
rxSocket.post('questions').subscribe(({req, res, next}) => {});
rxSocket.patch('questions').subscribe(({req, res, next}) => {});
rxSocket.delete('questions').subscribe(({req, res, next}) => {});
rxSocket.head('questions').subscribe(({req, res, next}) => {});

/**
 * Server sent messages - possible other verbs? send, emit, write
 *
 * @param {string} messageKey A unique message key which the client can subscribe to
 * @param {any} data An arbitrary data value sent to the client
 */
rxSocket.push('newPost', {some: 'data'});