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

socket.io-ease

v1.0.2

Published

Use socket.io as the routes of express.js or adonis.js

Readme

Description

Socket.io-ease is a library that provides an abstraction layer on top of socket.io, integrating concepts from other popular libraries such as express.js and adonis.js. It aims to simplify the development of socket.io-based projects by providing a straightforward and well-organized structure.

Installation

To install Socket.io-ease, use either npm or yarn:

npm:

npm install socket.io-ease

yarn:

yarn add socket.io-ease

Usability

Once Socket.io-ease is installed, you can create a SocketServer instance by providing a server object or a port number as a parameter as a socket.io. Here's an example:

import { SocketServer } from "socket.io-ease";

const socketServer = new SocketServer();

You can then add listeners to the server by providing event names and controller functions. Here's an example:

import { SocketServer } from "socket.io-ease";
import server from "src/server";
import controller from "src/controller";

const socketServer = new SocketServer();
socketServer.addListener("example", controller); // listen in "/example" event
/*The server can be from any framework or library 
(express, koa, fastity, adoniss.js) or simply standalone*/
socketServer.start(server);

You can group listeners by using a callback that takes a SocketNode object as a parameter. Here's an example:

import { SocketServer, SocketNode } from "socket.io-ease";
import server from "src/server";
import controller from "src/controller";

const exampleGroup = (node: SocketNode) => {
  node.addListener("example", controller)
}

const socketServer = new SocketServer();
socketServer.addGroup(exampleGroup)
socketServer.start(server);

You can also add a prefix to a group of listeners by providing it as an option. Here's an example:

import { SocketServer, SocketNode } from "socket.io-ease";
import server from "src/server";
import controller from "src/controller";

const exampleGroup = (node: SocketNode) => {
  node.addListener("example", controller, { prefix: "foo" }) //listen in "/bee/foo/example" event
}

const socketServer = new SocketServer();
socketServer.addGroup(exampleGroup, { prefix: "bee" })
socketServer.start(server);

You can use middleware functions to handle incoming requests for a group of listeners as express or adonis. Here's an example:

import { SocketServer, SocketMiddleware, SocketConnection, SocketNext, SocketRequest } from "socket.io-ease";
import server from "src/server";
import controller from "src/controller";

class Middleware implements SocketMiddleware {
  handler: (request: SocketRequest, connection: SocketConnection, next: SocketNext) => {
    //some logic
    next()
  };
}

const exampleGroup = (node: SocketNode) => {
  node.addListener("example", controller, { middlewares: [Middleware] })
}

const socketServer = new SocketServer();
socketServer.addGroup(exampleGroup, { middlewares: [Middleware] })
socketServer.start(server);

Finally, here's an example of a controller function that can be used as a listener:

const controller = (request: SocketRequest, connection: SocketConnection) => { 
    //logic
}
export default controller